@@ -29,9 +29,6 @@ pipeline {
2929 }
3030
3131 environment {
32- SOURCEDIR = ' src'
33- // will also need to change notification section below
34- PATCHDIR = ' out'
3532 YETUS = ' yetus'
3633 // Branch or tag name. Yetus release tags are 'rel/X.Y.Z'
3734 YETUS_VERSION = ' f9ba0170a5787a5f4662d3769804fef0226a182f'
@@ -56,13 +53,44 @@ pipeline {
5653 }
5754 }
5855
56+ // Setup codebase so that each platform's build happens in its own exclusive copy of the
57+ // codebase.
58+ // Primarily because YETUS messes up the git branch information and affects the subsequent
59+ // optional stages after the first one.
60+ stage (' setup sources' ) {
61+ steps {
62+ dir(" ${ WORKSPACE} /centos-8" ) {
63+ sh ''' #!/usr/bin/env bash
64+
65+ cp -Rp ${WORKSPACE}/src ${WORKSPACE}/centos-8
66+ '''
67+ }
68+
69+ dir(" ${ WORKSPACE} /debian-10" ) {
70+ sh ''' #!/usr/bin/env bash
71+
72+ cp -Rp ${WORKSPACE}/src ${WORKSPACE}/debian-10
73+ '''
74+ }
75+
76+ dir(" ${ WORKSPACE} /ubuntu-focal" ) {
77+ sh ''' #!/usr/bin/env bash
78+
79+ cp -Rp ${WORKSPACE}/src ${WORKSPACE}/ubuntu-focal
80+ '''
81+ }
82+ }
83+ }
84+
5985 // This is an optional stage which runs only when there's a change in
6086 // C++/C++ build/platform.
6187 // This stage serves as a means of cross platform validation, which is
6288 // really needed to ensure that any C++ related/platform change doesn't
6389 // break the Hadoop build on Centos 8.
6490 stage (' precommit-run Centos 8' ) {
6591 environment {
92+ SOURCEDIR = " ${ WORKSPACE} /centos-8/src"
93+ PATCHDIR = " ${ WORKSPACE} /centos-8/out"
6694 DOCKERFILE = " ${ SOURCEDIR} /dev-support/docker/Dockerfile_centos_8"
6795 IS_OPTIONAL = 1
6896 }
@@ -78,10 +106,32 @@ pipeline {
78106 sh ''' #!/usr/bin/env bash
79107
80108 chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
81- "${SOURCEDIR}/dev-support/jenkins.sh"
109+ "${SOURCEDIR}/dev-support/jenkins.sh" run_ci
82110 '''
83111 }
84112 }
113+
114+ post {
115+ // Since this is an optional platform, we want to copy the artifacts
116+ // and archive it only if the build fails, to help with debugging.
117+ failure {
118+ sh ''' #!/usr/bin/env bash
119+
120+ cp -Rp "${WORKSPACE}/centos-8/out" "${WORKSPACE}"
121+ '''
122+ archiveArtifacts " out/**"
123+ }
124+
125+ cleanup() {
126+ script {
127+ sh ''' #!/usr/bin/env bash
128+
129+ chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
130+ "${SOURCEDIR}/dev-support/jenkins.sh" cleanup_ci_proc
131+ '''
132+ }
133+ }
134+ }
85135 }
86136
87137 // This is an optional stage which runs only when there's a change in
@@ -91,6 +141,8 @@ pipeline {
91141 // break the Hadoop build on Debian 10.
92142 stage (' precommit-run Debian 10' ) {
93143 environment {
144+ SOURCEDIR = " ${ WORKSPACE} /debian-10/src"
145+ PATCHDIR = " ${ WORKSPACE} /debian-10/out"
94146 DOCKERFILE = " ${ SOURCEDIR} /dev-support/docker/Dockerfile_debian_10"
95147 IS_OPTIONAL = 1
96148 }
@@ -106,16 +158,40 @@ pipeline {
106158 sh ''' #!/usr/bin/env bash
107159
108160 chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
109- "${SOURCEDIR}/dev-support/jenkins.sh"
161+ "${SOURCEDIR}/dev-support/jenkins.sh" run_ci
110162 '''
111163 }
112164 }
165+
166+ post {
167+ // Since this is an optional platform, we want to copy the artifacts
168+ // and archive it only if the build fails, to help with debugging.
169+ failure {
170+ sh ''' #!/usr/bin/env bash
171+
172+ cp -Rp "${WORKSPACE}/debian-10/out" "${WORKSPACE}"
173+ '''
174+ archiveArtifacts " out/**"
175+ }
176+
177+ cleanup() {
178+ script {
179+ sh ''' #!/usr/bin/env bash
180+
181+ chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
182+ "${SOURCEDIR}/dev-support/jenkins.sh" cleanup_ci_proc
183+ '''
184+ }
185+ }
186+ }
113187 }
114188
115189 // We want to use Ubuntu Focal as our main CI and thus, this stage
116190 // isn't optional (runs for all the PRs).
117191 stage (' precommit-run Ubuntu focal' ) {
118192 environment {
193+ SOURCEDIR = " ${ WORKSPACE} /ubuntu-focal/src"
194+ PATCHDIR = " ${ WORKSPACE} /ubuntu-focal/out"
119195 DOCKERFILE = " ${ SOURCEDIR} /dev-support/docker/Dockerfile"
120196 IS_OPTIONAL = 0
121197 }
@@ -131,69 +207,76 @@ pipeline {
131207 sh ''' #!/usr/bin/env bash
132208
133209 chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
134- "${SOURCEDIR}/dev-support/jenkins.sh"
210+ "${SOURCEDIR}/dev-support/jenkins.sh" run_ci
135211 '''
136212 }
137213 }
138- }
139214
140- }
215+ post {
216+ always {
217+ script {
218+ // Publish status if it was missed (YETUS-1059)
219+ withCredentials(
220+ [usernamePassword(credentialsId : ' 683f5dcf-5552-4b28-9fb1-6a6b77cf53dd' ,
221+ passwordVariable : ' GITHUB_TOKEN' ,
222+ usernameVariable : ' GITHUB_USER' )]) {
223+ sh ''' #!/usr/bin/env bash
141224
142- post {
143- always {
144- script {
145- // Publish status if it was missed (YETUS-1059)
146- withCredentials(
147- [usernamePassword(credentialsId : ' 683f5dcf-5552-4b28-9fb1-6a6b77cf53dd' ,
148- passwordVariable : ' GITHUB_TOKEN' ,
149- usernameVariable : ' GITHUB_USER' )]) {
150- sh ''' #!/usr/bin/env bash
151- YETUS_ARGS+=("--github-token=${GITHUB_TOKEN}")
152- YETUS_ARGS+=("--patch-dir=${WORKSPACE}/${PATCHDIR}")
153- TESTPATCHBIN="${WORKSPACE}/${YETUS}/precommit/src/main/shell/github-status-recovery.sh"
154- /usr/bin/env bash "${TESTPATCHBIN}" "${YETUS_ARGS[@]}" ${EXTRA_ARGS} || true
155- '''
156- }
225+ # Copy the artifacts of Ubuntu focal build to workspace
226+ cp -Rp "${WORKSPACE}/ubuntu-focal/out" "${WORKSPACE}"
227+
228+ # Send Github status
229+ chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
230+ "${SOURCEDIR}/dev-support/jenkins.sh" github_status_recovery
231+ '''
232+ }
157233
158- // Yetus output
159- archiveArtifacts " ${ env.PATCHDIR} /**"
160- // Publish the HTML report so that it can be looked at
161- // Has to be relative to WORKSPACE.
162- publishHTML (target : [
163- allowMissing : true ,
164- keepAll : true ,
165- alwaysLinkToLastBuild : true ,
166- // Has to be relative to WORKSPACE
167- reportDir : " ${ env.PATCHDIR} " ,
168- reportFiles : ' report.html' ,
169- reportName : ' Yetus Report'
170- ])
171- // Publish JUnit results
172- try {
173- junit " ${ env.SOURCEDIR} /**/target/surefire-reports/*.xml"
174- } catch (e) {
175- echo ' junit processing: ' + e. toString()
234+ // YETUS output
235+ archiveArtifacts " out/**"
236+
237+ // Publish the HTML report so that it can be looked at
238+ // Has to be relative to WORKSPACE.
239+ publishHTML (target : [
240+ allowMissing : true ,
241+ keepAll : true ,
242+ alwaysLinkToLastBuild : true ,
243+ // Has to be relative to WORKSPACE
244+ reportDir : " out" ,
245+ reportFiles : ' report.html' ,
246+ reportName : ' Yetus Report'
247+ ])
248+
249+ // Publish JUnit results
250+ try {
251+ junit " ${ SOURCEDIR} /**/target/surefire-reports/*.xml"
252+ } catch (e) {
253+ echo ' junit processing: ' + e. toString()
254+ }
255+ }
256+ }
257+
258+ cleanup() {
259+ script {
260+ sh ''' #!/usr/bin/env bash
261+
262+ chmod u+x "${SOURCEDIR}/dev-support/jenkins.sh"
263+ "${SOURCEDIR}/dev-support/jenkins.sh" cleanup_ci_proc
264+ '''
265+ }
266+ }
176267 }
177- }
178268 }
269+ }
179270
271+ post {
180272 // Jenkins pipeline jobs fill slaves on PRs without this :(
181273 cleanup() {
182274 script {
183- sh '''
184- # See YETUS-764
185- if [ -f "${WORKSPACE}/${PATCHDIR}/pidfile.txt" ]; then
186- echo "test-patch process appears to still be running: killing"
187- kill `cat "${WORKSPACE}/${PATCHDIR}/pidfile.txt"` || true
188- sleep 10
189- fi
190- if [ -f "${WORKSPACE}/${PATCHDIR}/cidfile.txt" ]; then
191- echo "test-patch container appears to still be running: killing"
192- docker kill `cat "${WORKSPACE}/${PATCHDIR}/cidfile.txt"` || true
193- fi
194- # See HADOOP-13951
195- chmod -R u+rxw "${WORKSPACE}"
196- '''
275+ sh ''' #!/usr/bin/env bash
276+
277+ # See HADOOP-13951
278+ chmod -R u+rxw "${WORKSPACE}"
279+ '''
197280 deleteDir()
198281 }
199282 }
0 commit comments