Reputation: 855
During a Google Cloud Build, is there a way to get information regarding the fact that the build is associated with a Pull Request like the Pull Request number/id for example?
It seems that no such substitution variable is available for the moment ref: https://cloud.google.com/cloud-build/docs/configuring-builds/substitute-variable-values
Upvotes: 0
Views: 1338
Reputation: 1153
Now they are available as CloudBuild environment variables. From the official document:
Cloud Build provides the following GitHub-specific default substitutions available for pull request triggers:
$_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
Upvotes: 2
Reputation: 645
Not from Github API, but you can get the PR# from command line:
$ hub pr list -f "%I%n" -h "$(git rev-parse --abbrev-ref HEAD)"
12345
Source: This blog post.
Upvotes: 0
Reputation: 4194
In GitHub, a single branch can be associated with multiple Pull Requests.
You can look up all PRs associated with a given branch ref using the GitHub API: https://developer.github.com/v3/pulls/
Cloud Build does not currently provide the Pull Request information, but if it did this would probably come from something like the Check Suite data, which also treats PRs as a list.
Upvotes: 1