@@ -18,26 +18,32 @@ buildScan {
18
18
value ' Jenkins Worker Label' , it
19
19
}
20
20
21
+ def isPrBuild = System . getenv(' ROOT_BUILD_CAUSE_GHPRBCAUSE' ) != null
22
+
21
23
// Capture changes included in this CI build except for pull request builds
22
- if (System . getenv(' GIT_COMMIT' ) && System . getenv( ' ROOT_BUILD_CAUSE_GHPRBCAUSE ' ) == null ) {
24
+ if (System . getenv(' GIT_COMMIT' ) && ! isPrBuild ) {
23
25
background {
24
26
def changes = " git diff --name-only ${ System.getenv('GIT_PREVIOUS_COMMIT')} ..${ System.getenv('GIT_COMMIT')} " . execute(). text. trim()
25
27
value ' Git Changes' , changes
26
28
}
27
29
}
28
- } else {
29
- tag ' LOCAL'
30
- }
31
30
32
- // Add SCM information
33
- def scmInfo = project. extensions. findByType(ScmInfoExtension )
34
- if (scmInfo && scmInfo. change && scmInfo. branch) {
35
- value ' Git Commit ID' , scmInfo. change
36
- // Don't tag the branch if we are in a detached head state
37
- if (scmInfo. branch ==~ / [0-9a-f]{5,40}/ == false ) {
38
- value ' Git Branch' , scmInfo. branch
39
- tag scmInfo. branch
31
+ // Add SCM information
32
+ if (isPrBuild) {
33
+ value ' Git Commit ID' , System . getenv(' ghprbActualCommit' )
34
+ value ' Git Branch' , System . getenv(' ghprbTargetBranch' )
35
+ tag System . getenv(' ghprbTargetBranch' )
36
+ tag " pr/${ System.getenv('ghprbPullId')} "
37
+ link ' Source' , " https://github.com/elastic/elasticsearch/tree/${ System.getenv('ghprbActualCommit')} "
38
+ link ' Pull Request' , System . getenv(' ghprbPullLink' )
39
+ } else {
40
+ def branch = System . getenv(' GIT_BRANCH' ). split(' /' ). last()
41
+ value ' Git Commit ID' , System . getenv(' GIT_COMMIT' )
42
+ value ' Git Branch' , branch
43
+ tag branch
44
+ link ' Source' , " https://github.com/elastic/elasticsearch/tree/${ System.getenv('GIT_COMMIT')} "
40
45
}
41
- link ' Source' , " https://github.com/elastic/elasticsearch/commit/${ scmInfo.change} "
46
+ } else {
47
+ tag ' LOCAL'
42
48
}
43
49
}
0 commit comments