Windows – How to run bat file in jenkins

batch-filecmdJenkinswindows

My jenkins is installed in C:\Program Files (x86)\Jenkins

bat file is located in C:\Users\Admin\workspace\demoWork\run.bat

When i run this bat file from cmd everything works fine. But when i try from jenkins executing batch command as mentioned in Image, Jenkins displays error as

Build step 'Execute Windows batch command' marked build as failure

enter image description here

Also inside jenkins folder automatically workspace folder gets created with Job title name. Can you guys please explain me in detail

Best Answer

Tatkal, you can't execute a command like in your image,

why don't you simply try

C:\users\admin\workspace\demowork\run.bat

or

call "C:\users\admin\workspace\demowork\run.bat"

"Also inside jenkins folder automatically workspace folder gets created with Job title name. Can you guys please explain me in detail" -

Jenkins creates folder with job title name automatically, saves jobs data and other build info... this is how it works. By default in jenkins job you can access your workspace using $WORKSPACE variable