Windows – Running bat files in Jenkins

batch-fileJenkinswindows

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

Best Answer

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.