我正在尝试通过Docker代理(google / cloud-sdk:alpine)运行jenkins管道,以将我的代码部署到App Engine。不幸的是,尽管我是docker的用户,但我对此没有许可。
问题往往与此帖子中的问题相同:Jenkins Pipeline gcloud problems in docker 但是,这个问题没有正确的答案。
当我手动启动这些命令时,一切正常。
我的Jenkins文件是:
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
答案 0 :(得分:0)
默认情况下,HOME = /
添加
HOME = $ WORKSPACE
之前
gcloud auth Activate-service-account --key-file = $ {GCP_SA}
为我工作