Skip to content

Commit eea1c74

Browse files
committed
Revert "Use updated environment variable for branch build scan metadata"
This reverts commit e3f9144
1 parent e3f9144 commit eea1c74

File tree

1 file changed

+20
-23
lines changed

1 file changed

+20
-23
lines changed

gradle/build-scan.gradle

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import org.elasticsearch.gradle.Architecture
2-
import org.elasticsearch.gradle.OS
3-
import org.elasticsearch.gradle.info.BuildParams
41
import org.gradle.initialization.BuildRequestMetaData
52

63
import java.util.concurrent.TimeUnit
@@ -14,14 +11,6 @@ buildScan {
1411
String jobName = System.getenv('JOB_NAME')
1512
String nodeName = System.getenv('NODE_NAME')
1613

17-
tag OS.current().name()
18-
tag Architecture.current().name()
19-
20-
// Tag if this build is run in FIPS mode
21-
if (BuildParams.inFipsJvm) {
22-
tag 'FIPS'
23-
}
24-
2514
// Automatically publish scans from Elasticsearch CI
2615
if (jenkinsUrl?.host?.endsWith('elastic.co')) {
2716
publishAlways()
@@ -33,7 +22,7 @@ buildScan {
3322
link 'System logs', "https://infra-stats.elastic.co/app/infra#/logs?" +
3423
"&logFilter=(expression:'host.name:${nodeName}',kind:kuery)"
3524
buildFinished {
36-
link 'System metrics', "https://infra-stats.elastic.co/app/metrics/detail/host/" +
25+
link 'System metrics', "https://infra-stats.elastic.co/app/infra#/metrics/host/" +
3726
"${nodeName}?_g=()&metricTime=(autoReload:!f,refreshInterval:5000," +
3827
"time:(from:${startTime - TimeUnit.MILLISECONDS.convert(5, TimeUnit.MINUTES)},interval:%3E%3D1m," +
3928
"to:${System.currentTimeMillis() + TimeUnit.MILLISECONDS.convert(5, TimeUnit.MINUTES)}))"
@@ -42,9 +31,6 @@ buildScan {
4231

4332
// Jenkins-specific build scan metadata
4433
if (jenkinsUrl) {
45-
// Disable async upload in CI to ensure scan upload completes before CI agent is terminated
46-
uploadInBackground = false
47-
4834
// Parse job name in the case of matrix builds
4935
// Matrix job names come in the form of "base-job-name/matrix_param1=value1,matrix_param2=value2"
5036
def splitJobName = jobName.split('/')
@@ -62,12 +48,10 @@ buildScan {
6248
value 'Job Name', jobName
6349
}
6450

65-
tag 'CI'
66-
link 'CI Build', buildUrl
67-
link 'GCP Upload', "https://console.cloud.google.com/storage/browser/_details/elasticsearch-ci-artifacts/jobs/${URLEncoder.encode(jobName, "UTF-8")}/build/${buildNumber}.tar.bz2"
68-
value 'Job Number', buildNumber
69-
tag System.getenv('JOB_BRANCH')
70-
value 'Git Branch', System.getenv('JOB_BRANCH')
51+
tag 'CI'
52+
link 'CI Build', buildUrl
53+
link 'GCP Upload', "https://console.cloud.google.com/storage/browser/_details/elasticsearch-ci-artifacts/jobs/${URLEncoder.encode(jobName, "UTF-8")}/build/${buildNumber}.tar.bz2"
54+
value 'Job Number', buildNumber
7155

7256
System.getenv().getOrDefault('NODE_LABELS', '').split(' ').each {
7357
value 'Jenkins Worker Label', it
@@ -77,13 +61,26 @@ buildScan {
7761
def isPrBuild = System.getenv('ROOT_BUILD_CAUSE_GHPRBCAUSE') != null
7862
if (isPrBuild) {
7963
value 'Git Commit ID', System.getenv('ghprbActualCommit')
64+
value 'Git Branch', System.getenv('ghprbTargetBranch')
65+
tag System.getenv('ghprbTargetBranch')
8066
tag "pr/${System.getenv('ghprbPullId')}"
8167
tag 'pull-request'
8268
link 'Source', "https://github.com/elastic/elasticsearch/tree/${System.getenv('ghprbActualCommit')}"
8369
link 'Pull Request', System.getenv('ghprbPullLink')
8470
} else {
85-
value 'Git Commit ID', BuildParams.gitRevision
86-
link 'Source', "https://github.com/elastic/elasticsearch/tree/${BuildParams.gitRevision}"
71+
if (System.getenv('GIT_BRANCH')) {
72+
def branch = System.getenv('GIT_BRANCH').split('/').last()
73+
value 'Git Branch', branch
74+
tag branch
75+
}
76+
if (System.getenv('GIT_COMMIT')) {
77+
value 'Git Commit ID', System.getenv('GIT_COMMIT')
78+
link 'Source', "https://github.com/elastic/elasticsearch/tree/${System.getenv('GIT_COMMIT')}"
79+
background {
80+
def changes = "git diff --name-only ${System.getenv('GIT_PREVIOUS_COMMIT')}..${System.getenv('GIT_COMMIT')}".execute().text.trim()
81+
value 'Git Changes', changes
82+
}
83+
}
8784
}
8885
} else {
8986
tag 'LOCAL'

0 commit comments

Comments
 (0)