Jenkins not running the scripts in update mode

Hi Team,

Hope everyone is doing good. I am a new member to this forum and Jenkins.
I am trying to run bat file from my local and bat file is on my server.

The Jenkins job runs fine and runs all the steps inside my bat file, however it does not update the records of my DB (thats what the bat file does when I run it from command prompt).
I am sharing the logs from my Jenkins job below

"
2021-10-26 11:28:06.223 Thread:TCP_CONTR_V - Thread:TCP_CONTR_V - Starting at 2021.10.26 11:28:06.223 EDT
2021-10-26 11:28:06.240 Thread:TCP_CONTR_V Cursor Fetchsize:1000
2021-10-26 11:28:06.240 Thread:TCP_CONTR_V Autocommit:false
2021-10-26 11:28:06.249 Thread:TCP_CONTR_V - updated 0 rows for table TCP_CONTR_V at 2021.10.26 11:28:06.249 EDT
2021-10-26 11:28:06.250 Thread:TCP_CONTR_V - updated 0 rows for table TCP_CONTR_V at 2021.10.26 11:28:06.250 EDT
2021-10-26 11:28:06.250 Thread:TCP_CONTR_V - updated 0 rows for table TCP_CONTR_V at 2021.10.26 11:28:06.250 EDT
2021-10-26 11:28:07.226 Approx max memory used:50,031k (5% of allocated)
2021-10-26 11:28:07.226 exit value = 2
2021-10-26 11:28:07.227 Sleeping for 500 milliseconds before exiting
Build step ‘Execute Windows batch command’ marked build as failure
Finished: FAILURE"

As I said this bat file runs fine when I run from the command prompt. But from the Jenkins job the records are not getting updated and job abends with the exit code 2 in the end.

Any suggestions will be helpful. Thanks

The context where the Jenkins agent (or Jenkins controller) runs the batch file is probably different than the context where you run the batch file successfully. Some of the things you might check include:

  • Is the same login user running the batch file in both cases?
  • Are the environment variables set to the same values in both cases?
  • Does the working directory in the failing case have significantly different content than the working directory in the case that works?
  • Is network access the same for the working case and the failing case?