通过 gcloud 命令行工具触发特定 git 提交的构建

Sau*_*nda 5 google-cloud-platform google-kubernetes-engine google-container-registry

我遇到的所有示例都采用以下格式:

gcloud container builds submit --config cloudbuild.yaml .
Run Code Online (Sandbox Code Playgroud)

手册页说明如下:

 [SOURCE]
    The source directory on local disk or tarball in Google Cloud Storage
    or disk to use for this build. If source is a local directory this
    command skips files specified in the .gcloudignore file (see $ gcloud
    topic gcloudignore for more information).
Run Code Online (Sandbox Code Playgroud)

现在,我本地磁盘上的源目录非常大,并且花费了大量时间将源代码从我的本地机器传输到 Google 构建服务器/云。是否有以下可能?如何?

  • 提供一个 git/github URL 而不是本地源目录
  • 我的 git-repo 也顺便反映在 Google Source Repository 中,因为我为我的 repo 设置了构建触发器。我可以提供 Google 镜像的存储库的 URL 吗?

Jas*_*all 3

不幸的是,今天在gcloud. 不过,您可以通过其他几种方式来完成此操作:

  1. 使用curl或您选择的客户端库发送 API 请求以请求指定RepoSource. 例如:

    { "source": { "repoSource": { "repoName": "my-repo", "commitSha": "deadbeef" } }, "steps": [...] }

  2. 在您的本地环境中,获取提交并使用以下命令构建它gcloud

    git checkout && gcloud 容器构建提交。--config=cloudbuild.yaml

  3. 创建一个自动执行构建的触发器,然后发出API 请求以在您想要的特定提交上手动运行触发器curl,再次使用客户端库。