Writing Data to excel, Same code works when I run directly in Katalon but when triggered from Jenkins i am getting below error

I am getting error in Jenkin for below program, same Custom keyword is passing in Katalon and writing the value in excel but when I trigger same test case from Jenkins it’s failing, any Idea?


   def void writeToExcel(int iRow, int iCell, String iText, String Workbook , String Sheetname ){

         //     FileInputStream file = new FileInputStream (new File("..\\\\FNolDetails.xlsx"))

         FileInputStream file = new FileInputStream (new File(Workbook))

         XSSFWorkbook workbook = new XSSFWorkbook(file);

         //     XSSFSheet sheet = workbook.getSheet("Smoke Result")

         XSSFSheet sheet = workbook.getSheet(Sheetname)

         //Write data to excel'

         Row oRow;

         oRow = sheet.getRow(iRow);

         if(oRow == null){


                oRow = sheet.getRow(iRow);


         Cell oCell;

         oCell = oRow.getCell(iCell - 1);

         if(oCell == null ){

                oRow.createCell(iCell - 1);

                oCell = oRow.getCell(iCell - 1);



         //FileOutputStream outFile =new FileOutputStream(new File("..\\\\FNolDetails.xlsx"));

         FileOutputStream outFile =new FileOutputStream(new File(Workbook));





Error in Jenkins

Hi @Roshan_SIngh

The log indicates that variable sheet is not initialized, therefore the null pointer exception is thrown. If you place a break point at

Chances are you’re gonna find sheet is empty. So perhaps the name of the sheet is incorrect. Or worse, the path to the file is wrong. You should consider and make sure those possibilities are not true.

Hope it helps

Thanks @ThanhTo
The same path is identified when i am running directly in Katalon. This Keyword i am using in almost all my test case to save my data… The issue is thrown for this keyword only when running same script in Jenkins.

@ThanhTo …You are right abut the path… When I’m using relative path in my script, Katalon is able to recognize the file path but Jenkins in unable to recognize hence above error is displayed while saving the data in excel.

I used full path now “C:\KatalonNew\FNolDetails.xlsx” and it worked. .

Earlier i was using “…\\FNolDetails.xlsx” in my script…
Relative path i used so that if other folks are using my script then i will work for them as well… Any suggestion?

1 Like

we are storing file paths for out test data in global variables that are updated by script based on system variables.
script on test suite level-

  1. read env. variabel
  2. if it’s empty (we are runnig localy) use value from global variable
  3. else set value to one that was set by environment (means we are running in bamboo/jenkins)