转到:在声明性Jenkinsfile中找不到

时间:2019-08-06 08:58:03

标签: docker go jenkins jenkins-pipeline

我在Docker上运行了Jenkins,在github上有以下Jenkinsfile

node {
    def root = tool name: 'Go 1.12.6', type: 'go'

    ws("${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_ID}/src/github.com/project/repo") {
        withEnv(["GOROOT=${root}", "GOPATH=${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_ID}/", "PATH+GO=${root}/bin"]) {
            env.PATH="${GOPATH}/bin:$PATH"

            stage('Clone repository') {
                checkout scm
            }


            stage('Test repo') {
                sh 'go test -v'
            }

            stage('Build image') {
                app = docker.build("docker/repo")
            }


            stage('Push image') { */
                docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-credentials') {
                    app.push("${env.BUILD_NUMBER}")
                    app.push("latest")
                }
            }
        }
    }
}

但是无论我尝试什么,都会出现以下错误:

+ go version
/var/jenkins_home/jobs/repo/builds/45/src/github.com/project/repo@tmp/durable-00e72894/script.sh: line 1: go: not found

1 个答案:

答案 0 :(得分:-1)

Jenkins重新启动可能只是解决了问题