簡體   English   中英

無法在 jenkins docker-agent 中使用 gcloud

[英]Unable to use gcloud in a jenkins docker-agent

我正在嘗試使用 docker 代理 (google/cloud-sdk:alpine) 運行 jenkins 管道,以將我的代碼部署到 App Engine。 不幸的是,盡管我是 docker 的根,但我似乎沒有權限這樣做。

這個問題往往與這篇文章中的問題相同: Jenkins Pipeline gcloud problems 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
                    '''
                }
            }
        }
    }
}

詹金斯的回報是:

[workspace] Running shell script
+ set +x
WARNING: Could not setup log file in /.config/gcloud/logs, (Error: Could not create directory [/.config/gcloud/logs/2018.12.28]: Permission denied.
Please verify that you have permissions to write to the parent directory.)
script returned exit code 1

默認首頁=/

添加
HOME=$WORKSPACE before gcloud auth activate-service-account --key-file=${GCP_SA}

為我工作

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM