11

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

Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
themaniac27
  • 1,109
  • 3
  • 15
  • 27

4 Answers4

27

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.

Jason Swager
  • 6,421
  • 6
  • 41
  • 56
  • 1
    Thank you soooooooooooo much. Wish you could help me with my dotopenauth problem – David Jan 31 '13 at 07:02
  • it's really helpful, not sure why in some jobs we can use CMD to run ,but in some jobs it cannot. anyway after remove the CMD /C and use the 'call' ,it worked now ,thanks . – Alter Hu Oct 12 '16 at 06:43
0

if you want to start a separate Command window you can try:

start cmd \k "your\bat"

here is a reference: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds.mspx?mfr=true

Fred Xue
  • 45
  • 6
0

I tried to do like this, first point it to the path where your bat file exists, and then 'call' command to trigger that bat file. As below:

cd yourFilePath

and then

call yourFile.bat
Michael
  • 3,093
  • 7
  • 39
  • 83
Rahul k
  • 69
  • 3
-1

Create file name jenkins.bat and place this file where your jenkins.war file is available.

You have to click jenkins.bat file.

Note :- After click on jenkins.bat file, chrome browser will automatically open with jenkins url.

Try this If your system configured with Java 8 or 7 Installation.

timeout 3
start chrome http://localhost:8080
timeout 3
java -jar jenkins.war

Try this If your system configured with Java 10 or above Installation.

timeout 3
start chrome http://localhost:8080
timeout 3
java -jar jenkins.war --enable-future-java
Jainish Kapadia
  • 2,603
  • 5
  • 18
  • 29