首页 文章

如何在 Cloud 构建器中访问私有Github存储库?

提问于
浏览
0

我在Github,A和B上有两个私有存储库 . 两个都是Golang项目 . 项目A依赖于存储库B.我已将两个存储库链接到Google源代码并同意权限 .

Cloudbuild.yaml

- name: 'gcr.io/cloud-builders/git'
   args: ['clone', 'https://source.developers.google.com/p/$PROJECT_ID/r/B']

从容器构建器记录

Starting Step #0
Step #0: Already have image (with digest): gcr.io/cloud-builders/git
Step #0: Cloning into 'B'...
Finished Step #0

...

Step #1: [0;33m[WARN]   [mUnable to checkout github.com/user/B
Step #1: [0;31m[ERROR]  [mUpdate failed for github.com/user/B: Unable to get repository: Cloning into '/builder/home/.glide/cache/src/B'...
Step #1: fatal: could not read Username for 'https://github.com': No such device or address
Step #1: : exit status 128

有没有人可以滑行与容器构建器和谷歌自己的源存储库一起工作?我不想使用“ Cloud 密钥管理服务”来解决这个问题 .

已经尝试过:https://github.com/GoogleCloudPlatform/cloud-builders/issues/44#issuecomment-325144047

1 回答

  • 1

    我没有使用 Cloud 构建的经验,但您应该使用ssh://而不是https://来克隆您的git存储库 . 那么你需要在repo中添加一个SSH密钥(在github中称为部署密钥,每个repo或你的用户帐户)并在克隆时使用相同的密钥(在Linux中它通常足以将私钥文件放在的〜/ .ssh) . 我猜你可能找到的涉及Cloud KMS的解决方案做同样的事情,但安全地存储私钥 .

相关问题