Skip to content

Commit 0a48e7a

Browse files
authored
Merge pull request #375 from gradle/cj/github-pr-base-branch
Capture GITHUB_BASE_REF as 'PR base branch' for GitHub PR builds
2 parents fc03fa9 + 02f6001 commit 0a48e7a

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

release/changes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
- [NEW] Add AI tag to the Build Scan when invoked by an AI Agent
22
- [NEW] Add custom value to the Build Scan indicating which AI Agent invoked the build
3-
- [NEW] Add link in Build Scan to GitHub PR
3+
- [NEW] Add link in Build Scan to GitHub PR
4+
- [NEW] For GitHub PRs, capture `GITHUB_BASE_REF` as the value `PR base branch`

src/main/java/com/gradle/CustomBuildScanEnhancements.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ private void execute() {
255255
Optional<String> runAttempt = envVariable("GITHUB_RUN_ATTEMPT");
256256
Optional<String> runNumber = envVariable("GITHUB_RUN_NUMBER");
257257
Optional<String> headRef = envVariable("GITHUB_HEAD_REF").filter(value -> !value.isEmpty());
258+
Optional<String> baseRef = envVariable("GITHUB_BASE_REF").filter(value -> !value.isEmpty());
258259
Optional<String> serverUrl = envVariable("GITHUB_SERVER_URL");
259260
Optional<String> gitRepository = envVariable("GITHUB_REPOSITORY");
260261
Optional<String> refName = envVariable("GITHUB_REF_NAME");
@@ -274,6 +275,8 @@ private void execute() {
274275
buildScan.value("CI run number", value));
275276
headRef.ifPresent(value ->
276277
buildScan.value("PR branch", value));
278+
baseRef.ifPresent(value ->
279+
buildScan.value("PR base branch", value));
277280

278281
if (serverUrl.isPresent() && gitRepository.isPresent() && runId.isPresent()) {
279282
StringBuilder githubActionsBuild = new StringBuilder(serverUrl.get())

0 commit comments

Comments
 (0)