代码之家  ›  专栏  ›  技术社区  ›  Agustin Castro

使用gcloud的jenkins管道不工作

  •  0
  • Agustin Castro  · 技术社区  · 7 年前

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

    gcloud auth activate服务帐户--密钥文件 ./service-account-creds.json警告:无法在中设置日志文件 [/.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'
                            }
                        }
                    }
                }
            }
        }
    

    1 回复  |  直到 7 年前
        1
  •  0
  •   gmc    7 年前

    试试这个:

    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}"
            }
        }
    }