【发布时间】:2023-04-05 01:42:01
【问题描述】:
在 Google Cloud 构建期间,有没有办法获取有关构建与拉取请求(例如拉取请求编号/ID)相关联的信息?
目前似乎没有这样的替代变量可用参考:https://cloud.google.com/cloud-build/docs/configuring-builds/substitute-variable-values
【问题讨论】:
在 Google Cloud 构建期间,有没有办法获取有关构建与拉取请求(例如拉取请求编号/ID)相关联的信息?
目前似乎没有这样的替代变量可用参考:https://cloud.google.com/cloud-build/docs/configuring-builds/substitute-variable-values
【问题讨论】:
在 GitHub 中,一个分支可以关联多个 Pull Request。
您可以使用 GitHub API 查找与给定分支 ref 关联的所有 PR:https://developer.github.com/v3/pulls/
Cloud Build 当前不提供拉取请求信息,但如果提供,则可能来自 Check Suite 数据之类的数据,该数据也将 PR 视为列表。
【讨论】:
不是来自 Github API,但你可以从命令行获取 PR#:
$ hub pr list -f "%I%n" -h "$(git rev-parse --abbrev-ref HEAD)"
12345
来源:这个blog post。
【讨论】:
现在它们可用作 CloudBuild 环境变量。来自官方文档:
Cloud Build 提供以下 GitHub 特定的默认值 可用于拉取请求触发器的替换:
$_HEAD_BRANCH : head branch of the pull request $_BASE_BRANCH : base branch of the pull request $_HEAD_REPO_URL : url of the head repo of the pull request $_PR_NUMBER : number of the pull request
【讨论】: