@@ -9,6 +9,13 @@ def host_ccache_dir
99
1010def thread_count = 10
1111
12+ // Remember the last Gitlab stage that was touched
13+ // This is used to ensure that pipelines are always properly "closed" in Gitlab
14+ // Such that they do not indefinitely remain in "Running".
15+ // This is a "hack" necessary in declarative pipelines, since the "gitlabBuilds"
16+ // command does not correctly push all initial stages.
17+ def last_gitlab_stage
18+
1219node(' docker' ) {
1320 user_id = sh(returnStdout : true , script : ' id -u' ). trim()
1421 user_name = sh(returnStdout : true , script : ' id -un' ). trim()
@@ -89,6 +96,9 @@ pipeline {
8996 stages {
9097 stage(' pnpm install' ) {
9198 steps {
99+ script {
100+ last_gitlab_stage = " Format JavaScript"
101+ }
92102 updateGitlabCommitStatus name : ' Overarching Pipeline' , state : ' running'
93103 updateGitlabCommitStatus name : ' Format JavaScript' , state : ' running'
94104 dir(' src/js' ) {
@@ -137,6 +147,9 @@ pipeline {
137147 }
138148 stage(' Building application - Single threaded' ) {
139149 steps {
150+ script {
151+ last_gitlab_stage = " Build - Single Threaded"
152+ }
140153 updateGitlabCommitStatus name : ' Build - Single Threaded' , state : ' running'
141154 dir(' build-st' ) {
142155 wt_configure(mt : ' OFF' )
@@ -158,6 +171,9 @@ pipeline {
158171 }
159172 stage(' Building application - Multi threaded' ) {
160173 steps {
174+ script {
175+ last_gitlab_stage = " Build - Multi Threaded"
176+ }
161177 updateGitlabCommitStatus name : ' Build - Multi Threaded' , state : ' running'
162178 dir(' build-mt' ) {
163179 wt_configure(mt : ' ON' )
@@ -179,6 +195,9 @@ pipeline {
179195 }
180196 stage(' Tests' ) {
181197 steps {
198+ script {
199+ last_gitlab_stage = " Tests"
200+ }
182201 updateGitlabCommitStatus name : ' Tests' , state : ' running'
183202 dir(' test' ) {
184203 warnError(' st test.wt failed' ) {
@@ -205,6 +224,9 @@ pipeline {
205224 }
206225 stage(' Test SQLite3' ) {
207226 steps {
227+ script {
228+ last_gitlab_stage = " Tests - Sqlite3"
229+ }
208230 updateGitlabCommitStatus name : ' Tests - Sqlite3' , state : ' running'
209231 dir(' test' ) {
210232 warnError(' st test.sqlite3 failed' ) {
@@ -237,6 +259,7 @@ pipeline {
237259 // Specific case to detect superseded builds.
238260 if (currentBuild. currentResult == ' NOT_BUILT' ) {
239261 updateGitlabCommitStatus name : ' Overarching Pipeline' , state : ' canceled'
262+ updateGitlabCommitStatus name : " ${ last_gitlab_stage} " , state : ' canceled'
240263 }
241264 }
242265 }
@@ -275,6 +298,9 @@ pipeline {
275298 stages {
276299 stage(' Wt-port Checkout' ) {
277300 steps {
301+ script {
302+ last_gitlab_stage = " Wt Port - Checkout"
303+ }
278304 updateGitlabCommitStatus name : ' Wt Port - Checkout' , state : ' running'
279305 script {
280306 // Checks out master by default.
@@ -315,6 +341,9 @@ pipeline {
315341 }
316342 stage(' Config' ) {
317343 steps {
344+ script {
345+ last_gitlab_stage = " Wt Port - Config"
346+ }
318347 updateGitlabCommitStatus name : ' Wt Port - Config' , state : ' running'
319348 dir(' wt-port/java' ) {
320349 sh """ cat > Config << EOF
@@ -339,6 +368,9 @@ EOF"""
339368 }
340369 stage(' CNOR' ) {
341370 steps {
371+ script {
372+ last_gitlab_stage = " Wt Port - CNOR"
373+ }
342374 updateGitlabCommitStatus name : ' Wt Port - CNOR' , state : ' running'
343375 // While this CAN be build with multiple threads it is generally a bad idea, as it is likely to fail at least once then.
344376 // The issue is that some of the grammar is build on-demand, and then used as an include.
@@ -365,6 +397,9 @@ EOF"""
365397 // This ought to be moved to a different step.
366398 stage(' Copy TinyMCE' ) {
367399 steps {
400+ script {
401+ last_gitlab_stage = " Wt Port - TinyMCE"
402+ }
368403 updateGitlabCommitStatus name : ' Wt Port - TinyMCE' , state : ' running'
369404 sh " cp -r /opt/tinymce/3/tinymce/jscripts/tiny_mce ${ env.WORKSPACE} /resources/"
370405 sh " cp -r /opt/tinymce/4/tinymce/js/tinymce ${ env.WORKSPACE} /resources/"
@@ -383,6 +418,9 @@ EOF"""
383418 }
384419 stage(' Clean-dist' ) {
385420 steps {
421+ script {
422+ last_gitlab_stage = " Wt Port - Java Build"
423+ }
386424 updateGitlabCommitStatus name : ' Wt Port - Java Build' , state : ' running'
387425 dir(' wt-port/java' ) {
388426 sh " make clean-dist -j${ thread_count} "
@@ -405,6 +443,9 @@ EOF"""
405443 }
406444 stage(' Test' ) {
407445 steps {
446+ script {
447+ last_gitlab_stage = " Wt Port - Java Test"
448+ }
408449 updateGitlabCommitStatus name : ' Wt Port - Java Test' , state : ' running'
409450 dir(' wt-port/java' ) {
410451 warnError(' tests failed' ) {
@@ -438,6 +479,7 @@ EOF"""
438479 // Specific case to detect superseded builds.
439480 if (currentBuild. currentResult == ' NOT_BUILT' ) {
440481 updateGitlabCommitStatus name : ' Overarching Pipeline' , state : ' canceled'
482+ updateGitlabCommitStatus name : " ${ last_gitlab_stage} " , state : ' canceled'
441483 }
442484 }
443485 }
0 commit comments