22@Library (' apm@current' ) _
33
44import co.elastic.matrix.*
5+ import groovy.transform.Field
6+
7+ /**
8+ This is the git commit sha which it's required to be used in different stages.
9+ It does store the env GIT_SHA
10+ */
11+ @Field def gitCommit
512
613pipeline {
714 agent none
@@ -42,6 +49,9 @@ pipeline {
4249 deleteDir()
4350 gitCheckout(basedir : " ${ BASE_DIR} " )
4451 stash allowEmpty : true , name : ' source' , useDefaultExcludes : false
52+ script {
53+ gitCommit = env. GIT_SHA
54+ }
4555 }
4656 }
4757 stage(' Sanity checks' ) {
@@ -60,36 +70,35 @@ pipeline {
6070 docker. image(' python:3.7-stretch' ). inside(" -e PATH=${ PATH} :${ env.WORKSPACE} /bin" ){
6171 dir(" ${ BASE_DIR} " ){
6272 // registry: '' will help to disable the docker login
63- preCommit(commit : " ${ GIT_BASE_COMMIT } " , junit : true , registry : ' ' )
73+ preCommit(commit : " ${ gitCommit } " , junit : true , registry : ' ' )
6474 }
6575 }
6676 }
6777 }
6878 }
6979 }
70- }
71- }
72- /**
73- Execute unit tests.
74- */
75- stage(' Test' ) {
76- agent { label ' linux && immutable' }
77- options {
78- timeout(time : 1 , unit : ' HOURS' )
79- skipDefaultCheckout()
80- }
81- steps {
82- withGithubNotify(context : ' Test' , tab : ' tests' ) {
83- deleteDir()
84- unstash " source"
85- dir(" ${ BASE_DIR} " ){
86- script {
87- def node = readYaml(file : ' .ci/.jenkins_python.yml' )
88- def parallelTasks = [:]
89- node[' PYTHON_VERSION' ]. each{ version ->
90- parallelTasks[" ${ version} " ] = generateStep(version)
91- }
92- parallel(parallelTasks)
80+ /**
81+ Execute unit tests.
82+ */
83+ stage(' Test' ) {
84+ options {
85+ timeout(time : 1 , unit : ' HOURS' )
86+ skipDefaultCheckout()
87+ }
88+ steps {
89+ withGithubNotify(context : ' Test' , tab : ' tests' ) {
90+ deleteDir()
91+ unstash " source"
92+ dir(" ${ BASE_DIR} " ){
93+ script {
94+ def node = readYaml(file : ' .ci/.jenkins_python.yml' )
95+ def parallelTasks = [:]
96+ node[' PYTHON_VERSION' ]. each{ version ->
97+ parallelTasks[" ${ version} " ] = generateStep(version)
98+ }
99+ parallel(parallelTasks)
100+ }
101+ }
93102 }
94103 }
95104 }
@@ -177,7 +186,7 @@ def generateStep(version){
177186 build(job : " apm-agent-python/apm-agent-python-downstream/${ branch} " ,
178187 parameters : [
179188 string(name : ' PYTHON_VERSION' , value : version),
180- string(name : ' BRANCH_SPECIFIER' , value : env . GIT_BASE_COMMIT ),
189+ string(name : ' BRANCH_SPECIFIER' , value : gitCommit ),
181190 string(name : ' MERGE_TARGET' , value : branch),
182191 ],
183192 propagate : true ,
0 commit comments