Jenkins Pipeline gcloud problems in docker

我的梦境 提交于 2019-12-11 16:57:35

问题


I'm trying to set up jenkins pipeline according to this article but instead use google container registry to push the docker images to.

The Problem: The part which fails me is this jenkinsfile stage block

stage ('Push Docker Image To Container Registry') {
  docker.image('google/cloud-sdk:alpine').inside {
      sh "echo ${env.GOOGLE_AUTH} > gcp-key.json"
      sh 'gcloud auth activate-service-account --key-file ./service-account-creds.json'
  }
}

The Error:

Please verify that you have permissions to write to the parent directory.)

ERROR: (gcloud.components.update) Could not create directory [/.config/gcloud]: Permission denied.

I can't run any command to do with gcloud as the error above is what i get all the time.

I tried create the "/.config" directory manually logged into the aws instance and open up the permission of the folder to everyone but that didn't help either.

I also can't find anywhere how to properly setup google cloud for jenkins pipeline using docker.

Any suggestions are greatly appreciated :)


回答1:


It looks like it's trying to write data directly into your root file system directory. The .config directory for gcloud would normally be in the following locations for username and/or root user:

/home/yourusername/.config/gcloud
/root/.config/gcloud

It looks like, for some reason, jenkins thinks the parent directory should be in /.

I would try checking where your cloud sdk config directories are on the machine you are running this on (and for the user the scripts runs as):

$ sudo find / -iname "gcloud"

And look for location similars to those printed above.

Could it be that the Cloud SDK is installed in a none standard location on the machine?



来源:https://stackoverflow.com/questions/48290088/jenkins-pipeline-gcloud-problems-in-docker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!