Docker中的Jenkins Pipeline gcloud问题 [英] Jenkins Pipeline gcloud problems in docker

查看:130
本文介绍了Docker中的Jenkins Pipeline gcloud问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据以下内容建立詹金斯管道 文章,而是使用Google容器注册表来将docker镜像推送到.

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

问题:让我失败的部分是这个jenkinsfile阶段块

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'
  }
}

错误:

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

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

我无法运行任何命令来处理gcloud,因为上面的错误是我一直得到的.

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

我尝试创建手动登录到aws实例的"/.config"目录,并向所有人开放该文件夹的权限,但这也无济于事.

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.

在任何地方,我也找不到如何使用docker为jenkins管道正确设置Google云的方法.

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

任何建议都将不胜感激:)

Any suggestions are greatly appreciated :)

推荐答案

似乎正在尝试将数据直接写入根文件系统目录. gcloud的.config目录通常位于用户名和/或root用户的以下位置:

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

由于某种原因,jenkins认为父目录应该位于/中.

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

我会尝试检查您的云sdk配置目录在运行它的机器上的位置(对于用户来说,脚本的运行方式为:)

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.

是否可以将Cloud SDK安装在计算机上的非标准位置?

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

这篇关于Docker中的Jenkins Pipeline gcloud问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆