【发布时间】:2018-05-04 03:32:32
【问题描述】:
我正在运行 Jenkins 服务器(在 docker 容器内)的谷歌云中运行虚拟机。我正在尝试为我的应用程序构建一个 Docker 映像,并使用 Jenkins 管道将其推送到 Google Container Registry。
我安装了所有必需的 Jenkins 插件: Google OAuth 凭据插件, Docker管道插件, Google Container Registry 身份验证插件
创建了一个具有存储管理员和对象查看者角色的服务帐户 + 密钥。已下载 json 文件。
使用 google 项目名称作为 id 和 json 键在 Jenkins 中创建了一个凭据。
-
我的构建管道代码如下所示:
stage('Build Image') { app = docker.build("<gcp-project-id>/<myproject>") } -
我的构建管道代码如下所示:
stage('Push Image') { docker.withRegistry('https://us.gcr.io', 'gcr:<gcp-project-id>') { app.push("${commit_id}") app.push("latest") }}
但是,构建在最后一步失败并出现此错误:
unauthorized: You don't have the needed permissions to perform this operation, and you may have invalid credentials. To authenticate your request, follow the steps in: https://cloud.google.com/container-registry/docs/advanced-authentication
我花了几个小时试图弄清楚这一点。任何帮助将不胜感激!
【问题讨论】:
标签: jenkins-pipeline google-container-registry