小编Flo*_*uin的帖子

无法在 jenkins docker-agent 中使用 gcloud

我正在尝试使用 docker 代理 (google/cloud-sdk:alpine) 运行 jenkins 管道,以将我的代码部署到 App Engine。不幸的是,尽管我是 docker 的 root,但我似乎没有权限这样做。

这个问题往往与这篇文章中的问题相同:Jenkins Pipeline gcloud issues in docker 但这个问题没有正确的答案。

当我手动启动这些命令时,一切正常。

我的詹金斯文件是:

pipeline {
    agent {
        docker { 
            image 'registry.hub.docker.com/google/cloud-sdk:alpine' 
            args '-v $HOME:/home -w /home'    
        }
    }
    stages {
        stage('Deploy') {
            steps {
                withCredentials([file(credentialsId: 'bnc-hub', variable: 'SECRET_JSON')]) {
                    sh '''
                    set +x
                    gcloud auth activate-service-account --key-file $SECRET_JSON
                    gcloud config set project bnc-hub
                    gcloud app deploy app.yaml
                    '''
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

詹金斯的回报是:

[workspace] Running shell script
+ set +x …
Run Code Online (Sandbox Code Playgroud)

jenkins docker gcloud jenkins-pipeline

2
推荐指数
1
解决办法
1417
查看次数

标签 统计

docker ×1

gcloud ×1

jenkins ×1

jenkins-pipeline ×1