【发布时间】:2020-10-08 20:30:13
【问题描述】:
根据 Cloud Build 文档中标题为访问私有 GitHub 存储库的note:
当您使用 Cloud Build 触发器运行构建时,您可以自动连接到您拥有的任何私有存储库,而无需将凭据存储在 Secret Manager 中。
基于此,我尝试 git clone 我的私人 GitHub 存储库(没有将 ssh 密钥从 Secret Manager 传输到 ssh 文件,文档指出使用构建触发器是不必要的)无济于事。在我的cloudbuild.yaml 文件中使用下面的 ssh:
steps:
- name: google/cloud-sdk:alpine
id: Clone repo
entrypoint: git
args: ['clone', 'git@github.com:my-org/my-repo.git']
导致错误:
Step #0: Host key verification failed.
Step #0: fatal: Could not read from remote repository.
并使用 https
args: ['clone', 'https://github.com/my-org/my-repo.git']
我明白了:
Step #0 - "Clone repo": fatal: could not read Username for 'https://github.com': No such device or address
有什么方法可以在cloudbuild.yaml 中克隆私有 GitHub 存储库,而无需在克隆之前将 ssh 密钥从 Secret Manager 繁琐地传输到卷?任何提示将不胜感激。
【问题讨论】:
-
我不明白。您添加的注释适用于 Cloud Build 中的触发器,您希望您的构建由 Cloud 构建触发器触发(在这种情况下,您不需要执行此操作)还是手动触发?
-
是的,无论您使用触发器还是在 CLI 上构建,都需要 cloudbuild.yaml。我的 cloudbuild.yaml 文件位于私有 GitHub 存储库中。每当推送特定标签时都会触发构建。在我的构建(在 cloudbuild.yaml 中配置)中,我必须克隆 git 存储库,对其进行编辑,然后再次推送。
标签: github ssh google-cloud-platform yaml google-cloud-build