使用gcloud的詹金斯管道无法正常工作

时间:2019-02-07 18:15:07

标签: jenkins-pipeline gcloud

我正在尝试使用gcloud设置jenkins管道,但出现以下错误:

  

gcloud auth激活服务帐户-密钥文件   ./service-account-creds.json警告:无法在以下位置设置日志文件   /.config/gcloud/logs,(错误:无法创建目录   [/.config/gcloud/logs/2019.02.07]:权限被拒绝。

代码:

stages {
        stage('build') {
            steps {
                withCredentials([file(credentialsId: 'google-container-registry', variable: 'GOOGLE_AUTH')]) {
                    script {
                        docker.image('google/cloud-sdk:latest').inside {
                            sh "echo ${GOOGLE_AUTH} > gcp-key.json"
                            sh 'gcloud auth activate-service-account --key-file ./service-account-creds.json'
                        }
                    }
                }
            }
        }
    }

Jenkins使用图像jenkins / jenkins在容器中运行

1 个答案:

答案 0 :(得分:0)

尝试一下:

withCredentials([file(credentialsId: 'google-container-registry', variable: 'GOOGLE_AUTH')]) {
    script {
        docker.image('google/cloud-sdk:latest').inside {
            sh "echo ${GOOGLE_AUTH} > gcp-key.json"
            sh "gcloud auth activate-service-account --key-file=${GOOGLE_AUTH}"
        }
    }
}
相关问题