Jenkins does not recognize command sh?

后端 未结 9 1912
心在旅途
心在旅途 2020-12-09 09:27

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(\'         


        
相关标签:
9条回答
  • 2020-12-09 10:09

    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.

    0 讨论(0)
  • 2020-12-09 10:13

    @XP84's solution worked for me. I was getting issue with running python3 on a Mac Jenkins, I added this to environment variable and it started working. Here's a screenshot if anyone was like me and was having trouble inputting the actual values in respective fields.

    0 讨论(0)
  • 2020-12-09 10:13

    I tried all the above... but didn't work until I included in my steps container() for some reasons when Jenkins is trying to run the .sh file it's trying on Jenkins master, even if my agent is set up:

    agent {
        label "gen-java-slave"
    }
    

    Glob ENV:

    environment {
            PATH = "/usr/local/openjdk-11/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
    
    }
    

    Example of a working stage:

                stage('Create a Dump for Senapt Arango DB') {
    
                    steps {
                    container('general-container-name') {
                    withEnv(['PATH+EXTRA=/usr/bin/arangodump']) {  
                    sh '''
                        ./backup-arango-senapt.sh
                    '''
                    }
                    }
                    }
    
    0 讨论(0)
提交回复
热议问题