From c826e5ee65d570d29c50919da320fc31335834d4 Mon Sep 17 00:00:00 2001 From: Mark Vieira Date: Tue, 9 Jan 2024 15:25:04 -0800 Subject: [PATCH] Tag individual CI job name axis in build scans (#104168) # Conflicts: # .buildkite/pipelines/periodic.template.yml --- .buildkite/pipelines/periodic.template.yml | 6 +++--- .buildkite/pipelines/periodic.yml | 4 ++-- .../src/main/groovy/elasticsearch.build-scan.gradle | 12 +++++++++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.buildkite/pipelines/periodic.template.yml b/.buildkite/pipelines/periodic.template.yml index fab36deb6124a..1a1cc326c3a3a 100644 --- a/.buildkite/pipelines/periodic.template.yml +++ b/.buildkite/pipelines/periodic.template.yml @@ -180,14 +180,14 @@ steps: image: family/elasticsearch-ubuntu-2004 machineType: n2-standard-8 buildDirectory: /dev/shm/bk - if: build.branch == "main" || build.branch =~ /^[0-9]+\.[0-9]+\$/ - - label: Check branch consistency + if: build.branch == "main" || build.branch == "7.17" + - label: check-branch-consistency command: .ci/scripts/run-gradle.sh branchConsistency timeout_in_minutes: 15 agents: provider: gcp image: family/elasticsearch-ubuntu-2004 machineType: n2-standard-2 - - label: Check branch protection rules + - label: check-branch-protection-rules command: .buildkite/scripts/branch-protection.sh timeout_in_minutes: 5 diff --git a/.buildkite/pipelines/periodic.yml b/.buildkite/pipelines/periodic.yml index 7a4133326fdd6..db57b5c452adf 100644 --- a/.buildkite/pipelines/periodic.yml +++ b/.buildkite/pipelines/periodic.yml @@ -1292,13 +1292,13 @@ steps: machineType: n2-standard-8 buildDirectory: /dev/shm/bk if: build.branch == "main" || build.branch == "7.17" - - label: Check branch consistency + - label: check-branch-consistency command: .ci/scripts/run-gradle.sh branchConsistency timeout_in_minutes: 15 agents: provider: gcp image: family/elasticsearch-ubuntu-2004 machineType: n2-standard-2 - - label: Check branch protection rules + - label: check-branch-protection-rules command: .buildkite/scripts/branch-protection.sh timeout_in_minutes: 5 diff --git a/build-tools-internal/src/main/groovy/elasticsearch.build-scan.gradle b/build-tools-internal/src/main/groovy/elasticsearch.build-scan.gradle index b7f3932effa96..ac0f331d6007b 100644 --- a/build-tools-internal/src/main/groovy/elasticsearch.build-scan.gradle +++ b/build-tools-internal/src/main/groovy/elasticsearch.build-scan.gradle @@ -98,7 +98,8 @@ buildScan { 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) : "" - def jobName = (System.getenv('BUILDKITE_LABEL') ?: '').replaceAll(/[^a-zA-Z0-9_\-]+/, ' ').trim().replaceAll(' ', '_').toLowerCase() + def jobLabel = System.getenv('BUILDKITE_LABEL') ?: '' + def jobName = safeName(jobLabel) tag 'CI' link 'CI Build', "${buildKiteUrl}#${System.getenv('BUILDKITE_JOB_ID')}" @@ -111,6 +112,11 @@ buildScan { value 'Job Name', jobName tag jobName + if (jobLabel.contains("/")) { + jobLabel.split("/").collect {safeName(it) }.each {matrix -> + tag matrix + } + } if (branch) { tag branch @@ -161,3 +167,7 @@ buildScan { } } } + +static def safeName(String string) { + return string.replaceAll(/[^a-zA-Z0-9_\-\.]+/, ' ').trim().replaceAll(' ', '_').toLowerCase() +}