Skip to content

Commit

Permalink
Include branch information in build scans for buildkite jobs (elastic…
Browse files Browse the repository at this point in the history
…#101284)

# Conflicts:
#	build-tools-internal/src/main/groovy/elasticsearch.build-scan.gradle
  • Loading branch information
mark-vieira committed Oct 24, 2023
1 parent ac783bb commit 192a155
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,21 @@ buildScan {
// Disable async upload in CI to ensure scan upload completes before CI agent is terminated
uploadInBackground = false

def branch = System.getenv('BUILDKITE_BRANCH')
def branch = System.getenv('BUILDKITE_PULL_REQUEST_BASE_BRANCH') ?: System.getenv('BUILDKITE_BRANCH')
def repoMatcher = System.getenv('BUILDKITE_REPO') =~ /(https:\/\/github\.com\/|git@github\.com:)(\S+)\.git/
def repository = repoMatcher.matches() ? repoMatcher.group(2) : "<unknown>"
def jobName = (System.getenv('BUILDKITE_LABEL') ?: '').replaceAll(/[^a-zA-Z0-9_\-]+/, ' ').trim().replaceAll(' ', '_').toLowerCase()

tag 'CI'
link 'CI Build', buildKiteUrl
value 'Job Number', System.getenv('BUILDKITE_BUILD_NUMBER')


if (branch) {
tag branch
value 'Git Branch', branch
}

// Add SCM information
def prId = System.getenv('BUILDKITE_PULL_REQUEST')
if (prId != 'false') {
Expand All @@ -123,7 +130,6 @@ buildScan {
} else {
value 'Git Commit ID', BuildParams.gitRevision
link 'Source', "https://github.com/${repository}/tree/${BuildParams.gitRevision}"
tag branch
}

buildScanPublished { scan ->
Expand Down

0 comments on commit 192a155

Please sign in to comment.