Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running bat files in Jenkins

I have a simple question. I want to run a bat file that should run post build. The bat file takes in to parameters previousVersion and currentVersion (These parameters are entered as Validating String Parameters before the build starts).

This is what I have tried Execute Windows Batch Command

set v = %currentVersion%
set pv = %previousVersion%
cmd \k "C:\jenkins\workspace\mybatfile.bat %pv% %p%"

The error I get is that cmd is not recognized as an internal or external command operable program or batch file exit 9009

like image 352
themaniac27 Avatar asked Apr 19 '12 12:04

themaniac27


People also ask

How do I run a bat file in Jenkins?

Add the batch command as run. Click on Apply and save the configuration then, you will redirect to the Project Workspace. Click on the Build Now, it will execute the given batch command that executes the run. bat file. You can see the console results on the Console Output.


1 Answers

Replace "cmd \k" with "call"

The Execute Windows Batch command is running inside a cmd already; no need to specifically start a new one. Just "call" your BAT file.

like image 93
Jason Swager Avatar answered Oct 02 '22 10:10

Jason Swager