【问题标题】:Bitbucket Pipelines: pulling an image from GCR with environment variables failsBitbucket Pipelines:使用环境变量从 GCR 中提取图像失败
【发布时间】:2017-02-17 15:22:22
【问题描述】:

所以我正在尝试使用我的 Google 容器注册表中的图像,因为这是我需要进行身份验证的私有注册表。

显然我不想每小时更新我的​​身份验证令牌以使我的管道正常工作,所以我需要去获取 json 密钥文件。

当我按如下方式定义图像时它可以工作:

image:
   name: eu.gcr.io/project_id/image:latest
   username: _json_key
   password: >
      {JSON file content}
   email: pipelines@bitbucket.com

但这意味着您的 json 密钥文件已公开,可供所有有权访问管道的人查看,而不是我想要的。

然后我将 JSON 文件的内容放入环境变量中,并将实际的 json 替换为环境变量,如下所示:

image:
   name: eu.gcr.io/project_id/image:latest
   username: _json_key
   password: >
      ${JSON_KEY}
   email: pipelines@bitbucket.com

不知何故,在第二种情况下它不起作用:(

【问题讨论】:

  • 你是如何设置环境变量的?由于我从 GCP 获得的 JSON 密钥包含换行符 - 我是否只需删除这些?
  • 如果我没记错的话,bitbucket 会自动删除这些,所以你应该能够将粘贴复制到 bitbucket 管道配置中的 ENV 变量中。 (repo -> 设置 -> 在标题“管道”下 - 环境变量)

标签: google-container-registry bitbucket-pipelines


【解决方案1】:

经过更多测试,我发现这行得通:

image:
   name: eu.gcr.io/project_id/image:latest
   username: _json_key
   password: '$JSON_KEY'

【讨论】:

  • 这给了我一个401 Unauthorized 错误
猜你喜欢
  • 1970-01-01
  • 2019-07-05
  • 2018-02-05
  • 2021-09-19
  • 2021-07-27
  • 1970-01-01
  • 2017-12-10
  • 1970-01-01
  • 2018-02-09
相关资源
最近更新 更多