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(\'
Jenkins doesn't know what you mean by sh
nohup: failed to run command `sh': No such file or directory
This means the executable for your shell is not in your path. Go to Manage Jenkins -> Configure System scroll down until you find the section labelled Shell
Add the path to the executable you want to use for your shell when you call sh. Alternatively make sure the location for the executable for sh is in the path being used by your Jenkins instance (which depending on other factors, may or may not be the same as the system path).
Some examples
On windows you might want sh to mean powershell*. You would do this by setting the shell path to point at powershell.
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
If you are on *nix Jenkins will probably default to use whatever shell sh is already defined as for the user Jenkins is running under, but you could specify the path to a particular shell so jenkins will always use that shell. For example to always run sh as bash one could specify
/bin/bash
*Given that Jenkins has specific build steps for windows batch and powershell commands I tend to think of the Shell specifically as a *nix style shell. On a windows system you would need to install some sort of shell emulator, such as Cygwin.