Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-33708

Invocation of 'sh' on Windows should provide a more helpful error

    Details

    • Similar Issues:

      Description

      Right now if your pipeline script inadvertently tries to invoke the sh step, something approximating this error will fail your build:

      java.io.IOException: Cannot run program "nohup" (in directory "C:\Program Files (x86)\Jenkins\workspace\fathertime"): CreateProcess error=2, The system cannot find the file specified
      	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:815)
      	at hudson.Launcher$ProcStarter.start(Launcher.java:381)
      	at org.jenkinsci.plugins.durabletask.BourneShellScript.launchWithCookie(BourneShellScript.java:130)
      	at org.jenkinsci.plugins.durabletask.FileMonitoringTask.launch(FileMonitoringTask.java:59)
      	at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.start(DurableTaskStep.java:98)
      	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:136)
      	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:113)
      	at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1277)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1171)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1021)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:812)
      	at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
      	at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1277)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1171)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1021)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      	at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:15)
      	at WorkflowScript.run(WorkflowScript:11)
      	at ___cps.transform___(Native Method)
      	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:55)
      	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:106)
      	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:79)
      	at sun.reflect.GeneratedMethodAccessor174.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      	at java.lang.reflect.Method.invoke(Unknown Source)
      	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
      	at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
      	at com.cloudbees.groovy.cps.Next.step(Next.java:58)
      	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:154)
      	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:164)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:277)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$000(CpsThreadGroup.java:77)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:186)
      	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:184)
      	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:47)
      	at java.util.concurrent.FutureTask.run(Unknown Source)
      	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
      	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
      	at java.util.concurrent.FutureTask.run(Unknown Source)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      	at java.lang.Thread.run(Unknown Source)
      Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
      	at java.lang.ProcessImpl.create(Native Method)
      	at java.lang.ProcessImpl.<init>(Unknown Source)
      	at java.lang.ProcessImpl.start(Unknown Source)
      	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:815)
      	at hudson.Launcher$ProcStarter.start(Launcher.java:381)
      	at org.jenkinsci.plugins.durabletask.BourneShellScript.launchWithCookie(BourneShellScript.java:130)
      	at org.jenkinsci.plugins.durabletask.FileMonitoringTask.launch(FileMonitoringTask.java:59)
      	at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.start(DurableTaskStep.java:98)
      	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:136)
      	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:113)
      	at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1277)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1171)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1021)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:812)
      	at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:46)
      	at groovy.lang.MetaClassImpl.invokeMethodOnGroovyObject(MetaClassImpl.java:1277)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1171)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1021)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      	at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:15)
      	... 24 more
      Finished: FAILURE
      

      I expect the build to error out, but something more helpful would be nice, like "The `sh` step is not supported on the Windows platform, please use `bat` or install Cygwin"

        Attachments

          Issue Links

            Activity

            rtyler R. Tyler Croy created issue -
            Hide
            docwhat Christian Höltje added a comment -

            Based on a normal FreeStyle job, I would expect `sh` to work the same. An example I would expect to work on Windows:

            sh('''#!c:\path\to\bash.exe
            
            echo "I am in bash"
            ''')
            
            Show
            docwhat Christian Höltje added a comment - Based on a normal FreeStyle job, I would expect `sh` to work the same. An example I would expect to work on Windows: sh('''#!c:\path\to\bash.exe echo "I am in bash" ''')
            Hide
            peschmae peschmae peschmae added a comment - - edited

            I got it working on my system with the shell from git-bash.

            1. C:\Program Files\Git\bin is in the global search path, such that Jenkins finds sh.exe
            2. Jenkins also needs nohup.exe (as the error message suggests, see also BourneshellScript.java). Git-bash has a nohup.exe in /usr/bin. I just symlinked that (along with the shared libraries it needs) into /bin by running from a Windows cmd shell:
              mklink "C:\Program Files\Git\bin\nohup.exe" "C:\Program Files\git\usr\bin\nohup.exe"
              mklink "C:\Program Files\Git\bin\msys-2.0.dll" "C:\Program Files\git\usr\bin\msys-2.0.dll"
              mklink "C:\Program Files\Git\bin\msys-iconv-2.dll" "C:\Program Files\git\usr\bin\msys-iconv-2.dll"
              mklink "C:\Program Files\Git\bin\msys-intl-8.dll" "C:\Program Files\git\usr\bin\msys-intl-8.dll"
              

            With that setup it's working just fine on my machines.

            Show
            peschmae peschmae peschmae added a comment - - edited I got it working on my system with the shell from git-bash. C:\Program Files\Git\bin is in the global search path, such that Jenkins finds sh.exe Jenkins also needs nohup.exe (as the error message suggests, see also BourneshellScript.java ). Git-bash has a nohup.exe in /usr/bin. I just symlinked that (along with the shared libraries it needs) into /bin by running from a Windows cmd shell: mklink "C:\Program Files\Git\bin\nohup.exe" "C:\Program Files\git\usr\bin\nohup.exe" mklink "C:\Program Files\Git\bin\msys-2.0.dll" "C:\Program Files\git\usr\bin\msys-2.0.dll" mklink "C:\Program Files\Git\bin\msys-iconv-2.dll" "C:\Program Files\git\usr\bin\msys-iconv-2.dll" mklink "C:\Program Files\Git\bin\msys-intl-8.dll" "C:\Program Files\git\usr\bin\msys-intl-8.dll" With that setup it's working just fine on my machines.
            rtyler R. Tyler Croy made changes -
            Field Original Value New Value
            Workflow JNJira [ 169677 ] JNJira + In-Review [ 183601 ]
            jglick Jesse Glick made changes -
            Labels testfest diagnostics testfest
            jglick Jesse Glick made changes -
            Component/s durable-task-plugin [ 18622 ]
            Component/s workflow-plugin [ 18820 ]
            Labels diagnostics testfest diagnostics testfest windows workflow
            abayer Andrew Bayer made changes -
            Labels diagnostics testfest windows workflow diagnostics pipeline testfest windows workflow
            abayer Andrew Bayer made changes -
            Labels diagnostics pipeline testfest windows workflow diagnostics pipeline testfest windows
            julrich Jochen Ulrich made changes -
            Link This issue is related to JENKINS-32017 [ JENKINS-32017 ]
            Hide
            zaytsev Yury Zaytsev added a comment -

            Please just add a new WindowsCheck() next to the DarwinCheck(), I'm also using sh step on Windows with sh from msys, and I don't have nohup. This only makes life difficult for poor Windows users :-/ Thank you!

            Show
            zaytsev Yury Zaytsev added a comment - Please just add a new WindowsCheck() next to the DarwinCheck(), I'm also using sh step on Windows with sh from msys, and I don't have nohup. This only makes life difficult for poor Windows users :-/ Thank you!
            jglick Jesse Glick made changes -
            Link This issue relates to JENKINS-40225 [ JENKINS-40225 ]
            Hide
            flstaats Frederick Staats added a comment -

            I second the request to add WindowsCheck() on the line "if (!ws.act(new DarwinCheck()))

            { // JENKINS-25848" in src/main/java/org/jenkinsci/plugins/durabletask/BourneShellScript.java If you add Git Bash to a Windows master or slave node in the default "System Path", but the Path that is used to run the Windows Service that runs Jenkins does not include "nohup.exe" you run into an error as Jenkins is hardwired to run "nohup" using the Windows Service path running Jenkins and not the path configured for of the Pipeline executor. My work around to run Git Bash in Jenkins on Windows in a Pipeline step is to add a "C:\Nohup" directory with just "nohup.exe" and supporting DLLs into the global Path that is used by the Windows service, as it is not an option to add all of Git executables to the system level Path. Here is an example of the error when sh.exe (Bash) is on the path but nohup.exe is not on the path on Windows: [C:\Jenkins\workspace\Multibranch_Pipeline_master-HJ66KBORTDATZ4DJ3RHNWWLARKMDIQIPNIY5RCIPMIMMK37I2FUQ] Running shell script [Pipeline] }

            [Pipeline] // node
            [Pipeline] }
            [Pipeline] // stage
            [Pipeline] End of Pipeline

            GitHub has been notified of this commit’s build result

            java.io.IOException: Cannot run program "nohup" (in directory "C:\Jenkins\workspace\Multibranch_Pipeline_master-HJ66KBORTDATZ4DJ3RHNWWLARKMDIQIPNIY5RCIPMIMMK37I2FUQ"): CreateProcess error=2, The system cannot find the file specified
            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 org.jenkinsci.plugins.durabletask.BourneShellScript.launchWithCookie(BourneShellScript.java:147)
            at org.jenkinsci.plugins.durabletask.FileMonitoringTask.launch(FileMonitoringTask.java:61)
            at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.start(DurableTaskStep.java:158)
            at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:184)
            at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:126)
            at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108)
            at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source)
            at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
            at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
            at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:151)
            at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21)
            at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:115)
            at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149)
            at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146)
            at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
            at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123)
            at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16)
            at BREDev.call(C:\Jenkins\jobs\ITSD BREDev Multibranch

            Show
            flstaats Frederick Staats added a comment - I second the request to add WindowsCheck() on the line "if (!ws.act(new DarwinCheck())) { // JENKINS-25848" in src/main/java/org/jenkinsci/plugins/durabletask/BourneShellScript.java If you add Git Bash to a Windows master or slave node in the default "System Path", but the Path that is used to run the Windows Service that runs Jenkins does not include "nohup.exe" you run into an error as Jenkins is hardwired to run "nohup" using the Windows Service path running Jenkins and not the path configured for of the Pipeline executor. My work around to run Git Bash in Jenkins on Windows in a Pipeline step is to add a "C:\Nohup" directory with just "nohup.exe" and supporting DLLs into the global Path that is used by the Windows service, as it is not an option to add all of Git executables to the system level Path. Here is an example of the error when sh.exe (Bash) is on the path but nohup.exe is not on the path on Windows: [C:\Jenkins\workspace\Multibranch_Pipeline_master-HJ66KBORTDATZ4DJ3RHNWWLARKMDIQIPNIY5RCIPMIMMK37I2FUQ] Running shell script [Pipeline] } [Pipeline] // node [Pipeline] } [Pipeline] // stage [Pipeline] End of Pipeline GitHub has been notified of this commit’s build result java.io.IOException: Cannot run program "nohup" (in directory "C:\Jenkins\workspace\Multibranch_Pipeline_master-HJ66KBORTDATZ4DJ3RHNWWLARKMDIQIPNIY5RCIPMIMMK37I2FUQ"): CreateProcess error=2, The system cannot find the file specified 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 org.jenkinsci.plugins.durabletask.BourneShellScript.launchWithCookie(BourneShellScript.java:147) at org.jenkinsci.plugins.durabletask.FileMonitoringTask.launch(FileMonitoringTask.java:61) at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.start(DurableTaskStep.java:158) at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:184) at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:126) at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108) at groovy.lang.GroovyObject$invokeMethod.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:151) at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:21) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:115) at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:149) at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:146) at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123) at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:123) at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:16) at BREDev.call(C:\Jenkins\jobs\ITSD BREDev Multibranch
            Hide
            tantanntan Toshitaka Tandai added a comment -

            I Resolved this by arranging peschmae peschmae 's code above.try it

            mklink "C:\Program Files\Git\cmd\nohup.exe" "C:\Program Files\git\usr\bin\nohup.exe"
            mklink "C:\Program Files\Git\cmd\msys-2.0.dll" "C:\Program Files\git\usr\bin\msys-2.0.dll"
            mklink "C:\Program Files\Git\cmd\msys-iconv-2.dll" "C:\Program Files\git\usr\bin\msys-iconv-2.dll"
            mklink "C:\Program Files\Git\cmd\msys-intl-8.dll" "C:\Program Files\git\usr\bin\msys-intl-8.dll"
            
            

            but I met https://issues.jenkins-ci.org/browse/JENKINS-38211 ...

            Show
            tantanntan Toshitaka Tandai added a comment - I Resolved this by arranging peschmae peschmae 's code above.try it mklink "C:\Program Files\Git\cmd\nohup.exe" "C:\Program Files\git\usr\bin\nohup.exe" mklink "C:\Program Files\Git\cmd\msys-2.0.dll" "C:\Program Files\git\usr\bin\msys-2.0.dll" mklink "C:\Program Files\Git\cmd\msys-iconv-2.dll" "C:\Program Files\git\usr\bin\msys-iconv-2.dll" mklink "C:\Program Files\Git\cmd\msys-intl-8.dll" "C:\Program Files\git\usr\bin\msys-intl-8.dll" but I met https://issues.jenkins-ci.org/browse/JENKINS-38211 ...
            Hide
            medianick Nick Jones added a comment - - edited

            With Git for Windows 2.16.2, I was able to add C:\Program Files\Git\usr\bin to the PATH (rather than C:\Program Files\Git\bin) and consequently my sh commands work in both FreeStyle and Pipeline builds. No mklink was necessary.

            Show
            medianick Nick Jones added a comment - - edited With Git for Windows 2.16.2, I was able to add C:\Program Files\Git\usr\bin to the PATH (rather than C:\Program Files\Git\bin) and consequently my sh commands work in both FreeStyle and Pipeline builds. No mklink was necessary.
            Hide
            antgel Antony Gelberg added a comment - - edited

            Happening here as well with Git Bash, sadly the workarounds didn't work for me at all even when I altered PATH:

            pipeline {
              environment {
                PATH = "C:\\Program Files\\Git\\usr\\bin;C:\\Program Files\\Git\\bin;${env.PATH}"
              stages {
                stage('Sanity check') {
                  steps {
                    sh 'script/code_scan.sh'
                  }
                }
            ...
            

            I did bat 'sh -c script/code_scan.sh' instead ,which seems to work but is ugly and might hide gremlins.

            Errors were of the form:

            java.io.IOException: CreateProcess error=2, The system cannot find the file specified
            	at java.lang.ProcessImpl.create(Native Method)
            	at java.lang.ProcessImpl.<init>(Unknown Source)
            	at java.lang.ProcessImpl.start(Unknown Source)
            Also:   hudson.remoting.Channel$CallSiteStackTrace: Remote call to windows-server-2012 (i-09233a1df87ee74c0)
            		at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1737)
            		at hudson.remoting.UserResponse.retrieve(UserRequest.java:313)
            		at hudson.remoting.Channel.call(Channel.java:952)
            		at hudson.Launcher$RemoteLauncher.launch(Launcher.java:1052)
            		at hudson.Launcher$ProcStarter.start(Launcher.java:449)
            		at org.jenkinsci.plugins.durabletask.BourneShellScript.launchWithCookie(BourneShellScript.java:186)
            		at org.jenkinsci.plugins.durabletask.FileMonitoringTask.launch(FileMonitoringTask.java:71)
            		at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.start(DurableTaskStep.java:176)
            		at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:229)
            		at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:153)
            		at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108)
            		at sun.reflect.GeneratedMethodAccessor6254.invoke(Unknown Source)
            		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            		at java.lang.reflect.Method.invoke(Method.java:498)
            		at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
            		at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
            		at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
            		at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
            		at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
            		at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
            		at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
            		at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:157)
            		at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
            		at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:133)
            		at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:155)
            		at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:159)
            		at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:129)
            		at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
            		at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57)
            		at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
            		at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
            		at sun.reflect.GeneratedMethodAccessor198.invoke(Unknown Source)
            		at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            		at java.lang.reflect.Method.invoke(Method.java:498)
            		at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
            		at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
            		at com.cloudbees.groovy.cps.Next.step(Next.java:83)
            		at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
            		at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
            		at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:122)
            		at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:261)
            		at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
            		at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$101(SandboxContinuable.java:34)
            		at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.lambda$run0$0(SandboxContinuable.java:59)
            		at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
            		at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:58)
            		at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174)
            		at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:332)
            		at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:83)
            		at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:244)
            		at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:232)
            		at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
            		at java.util.concurrent.FutureTask.run(FutureTask.java:266)
            		at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
            		at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
            		at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
            		at java.util.concurrent.FutureTask.run(FutureTask.java:266)
            		at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
            		at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
            		at java.lang.Thread.run(Thread.java:748)
            Caused: java.io.IOException: Cannot run program "nohup" (in directory "c:\jenkins\workspace\web"): CreateProcess error=2, The system cannot find the file specified
            	at java.lang.ProcessBuilder.start(Unknown Source)
            	at hudson.Proc$LocalProc.<init>(Proc.java:249)
            	at hudson.Proc$LocalProc.<init>(Proc.java:218)
            	at hudson.Launcher$LocalLauncher.launch(Launcher.java:929)
            	at hudson.Launcher$ProcStarter.start(Launcher.java:449)
            	at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1299)
            	at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1259)
            	at hudson.remoting.UserRequest.perform(UserRequest.java:210)
            	at hudson.remoting.UserRequest.perform(UserRequest.java:53)
            	at hudson.remoting.Request$2.run(Request.java:364)
            	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
            	at java.util.concurrent.FutureTask.run(Unknown Source)
            	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
            	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
            	at java.lang.Thread.run(Unknown Source)
            
            Show
            antgel Antony Gelberg added a comment - - edited Happening here as well with Git Bash, sadly the workarounds didn't work for me at all even when I altered PATH : pipeline { environment { PATH = "C:\\Program Files\\Git\\usr\\bin;C:\\Program Files\\Git\\bin;${env.PATH}" stages { stage( 'Sanity check' ) { steps { sh 'script/code_scan.sh' } } ... I did bat 'sh -c script/code_scan.sh' instead ,which seems to work but is ugly and might hide gremlins. Errors were of the form: java.io.IOException: CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessImpl.create(Native Method) at java.lang.ProcessImpl.<init>(Unknown Source) at java.lang.ProcessImpl.start(Unknown Source) Also: hudson.remoting.Channel$CallSiteStackTrace: Remote call to windows-server-2012 (i-09233a1df87ee74c0) at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1737) at hudson.remoting.UserResponse.retrieve(UserRequest.java:313) at hudson.remoting.Channel.call(Channel.java:952) at hudson.Launcher$RemoteLauncher.launch(Launcher.java:1052) at hudson.Launcher$ProcStarter.start(Launcher.java:449) at org.jenkinsci.plugins.durabletask.BourneShellScript.launchWithCookie(BourneShellScript.java:186) at org.jenkinsci.plugins.durabletask.FileMonitoringTask.launch(FileMonitoringTask.java:71) at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.start(DurableTaskStep.java:176) at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:229) at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:153) at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108) at sun.reflect.GeneratedMethodAccessor6254.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:157) at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:133) at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:155) at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:159) at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:129) at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17) at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109) at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82) at sun.reflect.GeneratedMethodAccessor198.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72) at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21) at com.cloudbees.groovy.cps.Next.step(Next.java:83) at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174) at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163) at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:122) at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:261) at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$101(SandboxContinuable.java:34) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.lambda$run0$0(SandboxContinuable.java:59) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108) at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:58) at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:332) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:83) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:244) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:232) at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131) at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang. Thread .run( Thread .java:748) Caused: java.io.IOException: Cannot run program "nohup" (in directory "c:\jenkins\workspace\web" ): CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(Unknown Source) at hudson.Proc$LocalProc.<init>(Proc.java:249) at hudson.Proc$LocalProc.<init>(Proc.java:218) at hudson.Launcher$LocalLauncher.launch(Launcher.java:929) at hudson.Launcher$ProcStarter.start(Launcher.java:449) at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1299) at hudson.Launcher$RemoteLaunchCallable.call(Launcher.java:1259) at hudson.remoting.UserRequest.perform(UserRequest.java:210) at hudson.remoting.UserRequest.perform(UserRequest.java:53) at hudson.remoting.Request$2.run(Request.java:364) at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang. Thread .run(Unknown Source)
            Hide
            carelc Carel Combrink added a comment -

            I had to set the PATH System variable on the computer before I could get sh to work on Windows.

            Setting it in the  "List of variables" on the configuration page of the node in Jenkins allowed me to use the workaround as mentioned by Antony Gelberg
            Only once I set it in Windows and restarted the node could I use the "sh" command directly from within my script. 

            Show
            carelc Carel Combrink added a comment - I had to set the PATH System variable on the computer before I could get sh  to work on Windows. Setting it in the  "List of variables" on the configuration page of the node in Jenkins allowed me to use the workaround as mentioned by Antony Gelberg Only once I set it in Windows and restarted the node could I use the "sh" command directly from within my script. 
            Hide
            ethorsa ethorsa added a comment - - edited

            I had to set the PATH System variable on the computer before I could get sh to work on Windows.

            That's important, it doesn't work otherwise. Adding it to PATH from within the pipeline (eg. withEnv(...) or environment { ... }) doesn't work.

            Show
            ethorsa ethorsa added a comment - - edited I had to set the PATH System variable on the computer before I could get  sh  to work on Windows. That's important, it doesn't work otherwise. Adding it to PATH from within the pipeline (eg. withEnv(...)  or environment { ... }) doesn't work.

              People

              • Assignee:
                jglick Jesse Glick
                Reporter:
                rtyler R. Tyler Croy
              • Votes:
                14 Vote for this issue
                Watchers:
                21 Start watching this issue

                Dates

                • Created:
                  Updated: