[JIRA] [workflow-plugin] (JENKINS-33708) Invocation of 'sh' on Windows should provide a more helpful error

68 views
Skip to first unread message

tyler@monkeypox.org (JIRA)

unread,
Mar 21, 2016, 6:45:02 PM3/21/16
to jenkinsc...@googlegroups.com
R. Tyler Croy created an issue
 
Jenkins / Improvement JENKINS-33708
Invocation of 'sh' on Windows should provide a more helpful error
Issue Type: Improvement Improvement
Assignee: Jesse Glick
Components: workflow-plugin
Created: 2016/Mar/21 10:44 PM
Labels: testfest
Priority: Minor Minor
Reporter: R. Tyler Croy

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"

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.2#64017-sha1:e244265)
Atlassian logo

docwhat@gerf.org (JIRA)

unread,
Jun 22, 2016, 4:31:02 PM6/22/16
to jenkinsc...@googlegroups.com
Christian Höltje commented on Improvement JENKINS-33708
 
Re: Invocation of 'sh' on Windows should provide a more helpful error

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"
''')
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

3.14@gmx.ch (JIRA)

unread,
Jul 6, 2016, 8:12:02 AM7/6/16
to jenkinsc...@googlegroups.com

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 (as the error message suggests). Git-bash has a nohup in /usr/bin. I just symlinked that (along with the shared libraries it needs) int /bin:
Unable to find source-code formatter for language: bash. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
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.

3.14@gmx.ch (JIRA)

unread,
Jul 6, 2016, 8:17:05 AM7/6/16
to jenkinsc...@googlegroups.com
peschmae peschmae edited a comment on Improvement JENKINS-33708
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|https://github.com/jenkinsci/durable-task-plugin/blob/master/src/main/java/org/jenkinsci/plugins/durabletask/BourneShellScript.java]). Git-bash has a _nohup.exe_ in /usr/bin. I just symlinked that (along with the shared libraries it needs)
int into /bin by running from a Windows cmd shell :

{code:bash}

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"
{code}


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

3.14@gmx.ch (JIRA)

unread,
Jul 6, 2016, 8:17:05 AM7/6/16
to jenkinsc...@googlegroups.com
peschmae peschmae edited a comment on Improvement JENKINS-33708
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 _sh . exe exe_
# Jenkins *also* needs
nohup _nohup.exe_ (as the error message suggests , see also [BourneshellScript.java|https://github.com/jenkinsci/durable-task-plugin/blob/master/src/main/java/org/jenkinsci/plugins/durabletask/BourneShellScript.java] ). Git-bash has a nohup _nohup.exe_ in /usr/bin. I just symlinked that (along with the shared libraries it needs) int /bin:


{code:bash}
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"
{code}

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

3.14@gmx.ch (JIRA)

unread,
Jul 6, 2016, 8:17:07 AM7/6/16
to jenkinsc...@googlegroups.com
peschmae peschmae edited a comment on Improvement JENKINS-33708
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|https://github.com/jenkinsci/durable-task-plugin/blob/master/src/main/java/org/jenkinsci/plugins/durabletask/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:
{code:
bash java }

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"
{code}

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

jglick@cloudbees.com (JIRA)

unread,
Aug 2, 2016, 12:16:03 PM8/2/16
to jenkinsc...@googlegroups.com

jglick@cloudbees.com (JIRA)

unread,
Aug 2, 2016, 12:17:01 PM8/2/16
to jenkinsc...@googlegroups.com
Jesse Glick updated an issue
Change By: Jesse Glick
Component/s: durable-task-plugin
Component/s: workflow-plugin
Labels: diagnostics testfest windows workflow

yury@shurup.com (JIRA)

unread,
Nov 29, 2016, 2:18:01 PM11/29/16
to jenkinsc...@googlegroups.com
Yury Zaytsev commented on Improvement JENKINS-33708
 
Re: Invocation of 'sh' on Windows should provide a more helpful error

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!

frederick@staats.org (JIRA)

unread,
Dec 7, 2016, 8:15:03 PM12/7/16
to jenkinsc...@googlegroups.com

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

tantanntan@gmail.com (JIRA)

unread,
Jan 31, 2017, 8:16:03 AM1/31/17
to jenkinsc...@googlegroups.com

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 ...

medianick@gmail.com (JIRA)

unread,
Mar 23, 2018, 1:44:02 PM3/23/18
to jenkinsc...@googlegroups.com

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.

This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

medianick@gmail.com (JIRA)

unread,
Mar 23, 2018, 1:45:02 PM3/23/18
to jenkinsc...@googlegroups.com
Nick Jones edited a comment on Improvement JENKINS-33708

antony.gelberg@gmail.com (JIRA)

unread,
Apr 29, 2018, 6:36:06 AM4/29/18
to jenkinsc...@googlegroups.com

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)

antony.gelberg@gmail.com (JIRA)

unread,
Apr 29, 2018, 6:36:12 AM4/29/18
to jenkinsc...@googlegroups.com
Antony Gelberg edited a comment on Improvement JENKINS-33708
Happening here as well with Git Bash, sadly the workarounds didn't work for me at all even when I altered { { PATH} }
:

{code}

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'
      }
    }
...
{code}

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:
{code}
{code}

antony.gelberg@gmail.com (JIRA)

unread,
Apr 29, 2018, 6:37:05 AM4/29/18
to jenkinsc...@googlegroups.com

carel.combrink@gmail.com (JIRA)

unread,
Jun 28, 2018, 8:13:02 AM6/28/18
to jenkinsc...@googlegroups.com

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. 

This message was sent by Atlassian JIRA (v7.10.1#710002-sha1:6efc396)

ethorsa@inbox.lv (JIRA)

unread,
Dec 14, 2018, 3:07:04 AM12/14/18
to jenkinsc...@googlegroups.com
ethorsa commented on Improvement JENKINS-33708

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.

This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

ethorsa@inbox.lv (JIRA)

unread,
Dec 14, 2018, 5:52:03 AM12/14/18
to jenkinsc...@googlegroups.com
ethorsa edited a comment on Improvement JENKINS-33708
{quote}I had to set the PATH System variable on the computer before I could get {{sh}} to work on Windows.
{quote}

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

camposabates@gmail.com (JIRA)

unread,
Oct 3, 2019, 8:55:04 AM10/3/19
to jenkinsc...@googlegroups.com

The error related with : 
Cannot run program "nohup"
means that it's searching for nohup.exe because is what jenkins requires when using 'sh' in the pipeline, so you can use nuhup.exe from here: "C:\Program Files\Git\usr\bin".

Eventhough, what I have done in order to solve this issue is the following: Create a if else statement in your jenkinsfile that does:

     if (isUnix()) --> sh "command"

     else --> bat "command"

doing so the pipeline running on agent windows will run as bat and this error no longer appears.

Note: You can also use "tool config configuration" of jenkins and install tools from there. In case your sh commands were related with installation files

 

 

 

This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages