Reputation: 23
I'm trying to run a jenkins pipeline with a docker agent (google/cloud-sdk:alpine) to deploy my code to App Engine. Unfortunately, it seams I have no permission to to that although I'm root in the docker.
The issue tends to be the same as in this post : Jenkins Pipeline gcloud problems in docker But there is no right answer to this issue.
When I launch theses command by hand, everything works.
My Jenkinsfile is :
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
'''
}
}
}
}
}
The return in Jenkins is :
[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
Upvotes: 2
Views: 1587
Reputation: 66
By default HOME=/
Add
HOME=$WORKSPACE
before
gcloud auth activate-service-account --key-file=${GCP_SA}
worked for me
Upvotes: 5