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