I've been having a lot of trouble trying to get a Jenkinsfile to work. I've been trying to run this test script:
#!/usr/bin/env groovy node { stage('Build') { echo 'Building....' // Create virtualenv sh 'echo "hi"' } stage('Test') { echo 'Building....' } stage('Deploy') { echo 'Deploying....' } }
But I keep getting this error when trying to build:
Warning: JENKINS-41339 probably bogus PATH=/usr/lib64/ccache:/usr/lib64/ccache:$PATH; perhaps you meant to use ‘PATH+EXTRA=/something/bin’? [test-job-jenkinsfile-pipeline] Running shell script nohup: failed to run command `sh': No such file or directory
I updated all the pipeline plugins to the latest version and still run into this error. Any help?
sh : Shell ScriptLabel to be displayed in the pipeline step view and blue ocean details for the step instead of the step type. So the view is more meaningful and domain specific instead of technical. returnStatus : boolean (optional)
The sh.exe which is needed to run shell scripts is in the "bin" sub-directory, i.e. C:\cygwin64\bin. 2 - Tell Jenkins where sh.exe is located. Jenkins web console > Manage Jenkins > Configure System > Under shell, set the "Shell executable" = C:\cygwin64\bin\sh.exe > Click apply & also click save.
Running Script Console on agentsVisit "Manage Jenkins" > "Manage Nodes". Select any node to view the status page. In the menu on the left, a menu item is available to open a "Script Console" on that specific agent.
Jonathan's answer is correct in that modifying $PATH using the Jenkins Environment Variable settings causes this problem - but just deleting the PATH customizations you have will likely cause you to lose functionality, especially if you have any Freestyle type projects in your Jenkins.
See, in the entire rest of the universe it's very common to edit the $PATH by setting it to your new thing plus the existing $PATH, like this:
PATH=/opt/blah/bin:$PATH
This prepends /opt/blah/bin
to what's already in $PATH
. So the final $PATH
might look like: /opt/blah/bin:/usr/local/bin:/usr/sbin:/bin
(this is just an example of course)
This actually works fine for Jenkins Freestyle projects. However, for Pipeline projects Jenkins for some reason does not actually evaluate and replace the $PATH variable in the variable you've set. So you literally end up with a path of /opt/blah/bin:$PATH
- so nothing that was there before is still in your $PATH!
Apparently instead of just fixing that bug, Jenkins project decided to (1) detect the condition and display a weird warning ("Warning: JENKINS-41339 probably bogus") to imply you should check out that ticket and (2) create a brand new way of defining additions to PATH, which is the best solution to your problem because it allows you to customize the $PATH without breaking everything. You do this in Jenkins->Configure System.
Define a variable called PATH+EXTRA
where EXTRA can apparently be whatever.
In that variable, just put your additions for the PATH. So in my example above, I would NOT set PATH
at all, rather I'd just set: PATH+EXTRA=/opt/blah/bin
Now remove any defined PATH
variable.
According to a related ticket, this is documented somewhere in Jenkins, but is not documented in the place it needs to be, in Manage Jenkins->Configure System.
So it seems the reason was that the global property PATH
was causing the issue. By going to Manage Jenkins
-> Configure System
and deleting the PATH
global property solved my issue. See JENKINS-41339.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With