Sri
Sri

Reputation: 103

windows batch command in jenkins failed

I have setup Jenkins in Docker and am able to run some ANT script, I now have to run some 'windows batch script'. I gave a basic command echo "Hello" but I am getting the following error... I believe it is expecting cmd.exe to be in my work space??? Can some one please help me resolve this ? Thanks in advance.

[CI] $ cmd /c call /tmp/hudson5615964182226568321.bat
FATAL: command execution failed
java.io.IOException: Cannot run program "cmd" (in directory "/var/jenkins_home/workspace/CI"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at hudson.Proc$LocalProc.<init>(Proc.java:243)
at hudson.Proc$LocalProc.<init>(Proc.java:212)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:815)
at hudson.Launcher$ProcStarter.start(Launcher.java:381)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:95)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:64)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
at hudson.model.Build$BuildExecution.build(Build.java:205)
at hudson.model.Build$BuildExecution.doRun(Build.java:162)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
at hudson.model.Run.execute(Run.java:1720)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:404)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)

... 15 more Build step 'Execute Windows batch command' marked build as failure Finished: FAILURE

Upvotes: 6

Views: 14042

Answers (3)

twasbrillig
twasbrillig

Reputation: 18921

I got the same error on a Windows server. I had an Active Choices Parameter using a Scriptler Script, and I forgot to fill in the Name of the parameter.

Upvotes: 0

Rakesh Yadav
Rakesh Yadav

Reputation: 1985

In my case since jenkins is running on VM which is providing a Linux based system in Windows. We cannot execute Windows Batch Command becuase jenkins is running on Linux based VM.

So we have to run shell scripts. Just select Execute Shell instead of Execute Windows Batch Command

Upvotes: 3

writerrajiv
writerrajiv

Reputation: 114

Your Jenkins setup must be in Linux, and when you are selecting "Windows batch COmmand", the command won't work in Linux System. Hence, the system is describing to you that cmd cannot be executed in Uninx machine.

Cannot run program "cmd" (in directory "/var/jenkins_home/workspace/CI"): error=2, No such file or directory

Upvotes: 5

Related Questions