Search code examples
batch-filejenkinsjenkins-pipelineadminbackground-process

Jenkins Pipeline: How to run batch scripts in the background? [Corporate Domain]


I have a simple batch script written in Jenkins scripted Pipeline, that is executing an .exe-file with its own parameters, but to run it in desired way, admin rights are necessary. Once admin rights are present, my batch script is not delivering any output into the Jenkins's console. Is there a way how to force the Jenkins to run batch scripts in the background?

When running from a folder without admin rights, batch script's output and the script itself are running in the background and I'm getting all the console output I need. Nevertheless, some .exe files (some tests) will fail and won't even start (namely those ones, that have to communicate with my iOS test devices)

Once running from a folder with admin rights, all of my batch scripts are running smoothly, but in a separate cmd window and I'm not getting any output into the Jenkins's console.

stage('Build'){
bat "[path_to_msbuild]\\msbuild.exe .\\[path_to_solution]\\Test.sln"
}

stage('Start'){
bat "[path_to_built_exe]\\Test.exe /rc:TestRun /rf:[path_to_html_report]\\report.html /ju /zr /zrf:[path_to_rxzlog_report]\\report.rxzlog"        
}

Expected results: Output from batch scripts is being returned into the Jenkins' console at any circumstances.


Solution

  • It turned out to be admin rights problem. Our company has strict access policies and java process (Jenkins) was running without admin rights.