Run a command shell in jenkins

Med braim picture Med braim · May 21, 2015 · Viewed 116.8k times · Source

I'm trying to execute a command shell in Jenkins, I'm working on Windows 7. In the console output I have this:

Building in workspace C:\Program Files (x86)\Jenkins\workspace\test
[test] $ sh -xe C:\Windows\TEMP\hudson6299483223982766034.sh
The system cannot find the file specified

FATAL: L'exécution de la commande a échoué.
java.io.IOException: Cannot run program "sh" (in directory "C:\Program Files (x86)\Jenkins\workspace\test"): CreateProcess error=2, Le fichier spécifié est introuvable
    at java.lang.ProcessBuilder.start(Unknown Source)
    at hudson.Proc$LocalProc.<init>(Proc.java:244)
    at hudson.Proc$LocalProc.<init>(Proc.java:216)
    at hudson.Launcher$LocalLauncher.launch(Launcher.java:816)
    at hudson.Launcher$ProcStarter.start(Launcher.java:382)
    at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:97)
    at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:66)
    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:537)
    at hudson.model.Run.execute(Run.java:1744)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:374)
Caused by: java.io.IOException: CreateProcess error=2, Le fichier spécifié est introuvable
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(Unknown Source)
    at java.lang.ProcessImpl.start(Unknown Source)
    ... 16 more
Build step 'Exécuter un script shell' marked build as failure
[BFA] Scanning build for known causes...
[BFA] No failure causes found
[BFA] Done. 0s
Finished: FAILURE

Any idea?

Answer

mainframer picture mainframer · May 21, 2015

For Windows slave, please use Execute Windows batch command.
For Unix-like slave like linux or Mac, Execute shell is the option.

Execute Windows Command shell