@@ -4,38 +4,34 @@ import org.elasticsearch.gradle.OS
4
4
buildScan {
5
5
URL jenkinsUrl = System . getenv(' JENKINS_URL' ) ? new URL (System . getenv(' JENKINS_URL' )) : null
6
6
String buildNumber = System . getenv(' BUILD_NUMBER' )
7
+ String buildUrl = System . getenv(' BUILD_URL' )
7
8
String jobName = System . getenv(' JOB_NAME' )
8
9
9
10
tag OS . current(). name()
11
+ if (jobName) {
12
+ value ' Job name' , jobName
13
+ }
14
+ if (buildNumber) {
15
+ value ' Job number' , buildNumber
16
+ }
10
17
11
- // Accept Gradle ToS when project property org.elasticsearch.acceptScanTOS=true or this is an Elastic CI build
12
- if (jenkinsUrl?. host?. endsWith(' elastic.co' ) || Boolean . valueOf(project. findProperty(' org.elasticsearch.acceptScanTOS' ) ?: " false" )) {
13
- termsOfServiceUrl = ' https://gradle.com/terms-of-service'
14
- termsOfServiceAgree = ' yes'
18
+ if (jenkinsUrl?. host?. endsWith(' elastic.co' )) {
19
+ publishAlways()
20
+ buildScan. server = ' https://gradle-enterprise.elastic.co'
15
21
}
16
22
17
23
// Jenkins-specific build scan metadata
18
24
if (jenkinsUrl) {
19
25
tag ' CI'
20
- tag System . getenv(' JOB_NAME' )
21
- link ' Jenkins Build' , System . getenv(' BUILD_URL' )
22
- link ' Additional Logs' ,
23
- " https://console.cloud.google.com/storage/elasticsearch-ci-artifacts/jobs/${ jobName} /build/${ buildNumber} .tar.bz2"
24
- System . getenv(' NODE_LABELS' ). split(' ' ). each {
26
+ tag jobName
27
+ link ' Jenkins Build' , buildUrl
28
+ link ' GCP Upload' , " https://console.cloud.google.com/storage/elasticsearch-ci-artifacts/jobs/${ jobName} /build/${ buildNumber} .tar.bz2"
29
+ System . getenv(). getOrDefault(' NODE_LABELS' , ' ' ). split(' ' ). each {
25
30
value ' Jenkins Worker Label' , it
26
31
}
27
32
28
- def isPrBuild = System . getenv(' ROOT_BUILD_CAUSE_GHPRBCAUSE' ) != null
29
-
30
- // Capture changes included in this CI build except for pull request builds
31
- if (System . getenv(' GIT_COMMIT' ) && ! isPrBuild) {
32
- background {
33
- def changes = " git diff --name-only ${ System.getenv('GIT_PREVIOUS_COMMIT')} ..${ System.getenv('GIT_COMMIT')} " . execute(). text. trim()
34
- value ' Git Changes' , changes
35
- }
36
- }
37
-
38
33
// Add SCM information
34
+ def isPrBuild = System . getenv(' ROOT_BUILD_CAUSE_GHPRBCAUSE' ) != null
39
35
if (isPrBuild) {
40
36
value ' Git Commit ID' , System . getenv(' ghprbActualCommit' )
41
37
value ' Git Branch' , System . getenv(' ghprbTargetBranch' )
@@ -44,11 +40,19 @@ buildScan {
44
40
link ' Source' , " https://github.com/elastic/elasticsearch/tree/${ System.getenv('ghprbActualCommit')} "
45
41
link ' Pull Request' , System . getenv(' ghprbPullLink' )
46
42
} else {
47
- def branch = System . getenv(' GIT_BRANCH' ). split(' /' ). last()
48
- value ' Git Commit ID' , System . getenv(' GIT_COMMIT' )
49
- value ' Git Branch' , branch
50
- tag branch
51
- link ' Source' , " https://github.com/elastic/elasticsearch/tree/${ System.getenv('GIT_COMMIT')} "
43
+ if (System . getenv(' GIT_BRANCH' )) {
44
+ def branch = System . getenv(' GIT_BRANCH' ). split(' /' ). last()
45
+ value ' Git Branch' , branch
46
+ tag branch
47
+ }
48
+ if (System . getenv(' GIT_COMMIT' )) {
49
+ value ' Git Commit ID' , System . getenv(' GIT_COMMIT' )
50
+ link ' Source' , " https://github.com/elastic/elasticsearch/tree/${ System.getenv('GIT_COMMIT')} "
51
+ background {
52
+ def changes = " git diff --name-only ${ System.getenv('GIT_PREVIOUS_COMMIT')} ..${ System.getenv('GIT_COMMIT')} " . execute(). text. trim()
53
+ value ' Git Changes' , changes
54
+ }
55
+ }
52
56
}
53
57
} else {
54
58
tag ' LOCAL'
0 commit comments