Jenkins does not recognize command sh?

2020-02-26 05:40发布

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?

7条回答
爷、活的狠高调
2楼-- · 2020-02-26 06:40

Jenkins' most friendly and simplest solution while dealing with environment variables is to use Environment Injector Plugin

so to fix this issue you just need to do the following:

  1. Install Environment Injector Plugin
  2. Open your pipeline and enable Prepare an environment for the run check box and add PATH=/sbin:/usr/sbin:/usr/bin:/usr/local/bin:/bin inside Properties Content text box.
查看更多
登录 后发表回答