Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 2d3475b

Browse files
committed
Jenkinsfile: don't mark build failed when failing to create bundles
Failing to archive the bundles should not mark the build as failed. This can happen if a build is terminated early, or if (to be implemented) an optional build-stage is skipped / failed; ``` 2019-08-24T10:53:09.354Z] + bundleName=janky [2019-08-24T10:53:09.354Z] + echo Creating janky-bundles.tar.gz [2019-08-24T10:53:09.354Z] Creating janky-bundles.tar.gz [2019-08-24T10:53:09.354Z] + xargs tar -czf janky-bundles.tar.gz [2019-08-24T10:53:09.354Z] + find bundles -path */root/*overlay2 -prune -o -type f ( -name *-report.json -o -name *.log -o -name *.prof -o -name *-report.xml ) -print [2019-08-24T10:53:09.354Z] find: bundles: No such file or directory [2019-08-24T10:53:09.354Z] tar: Cowardly refusing to create an empty archive [2019-08-24T10:53:09.354Z] Try 'tar --help' or 'tar --usage' for more information. Error when executing always post condition: hudson.AbortException: script returned exit code 123 at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.handleExit(DurableTaskStep.java:569) at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.check(DurableTaskStep.java:515) at org.jenkinsci.plugins.workflow.steps.durable_task.DurableTaskStep$Execution.run(DurableTaskStep.java:461) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) ``` Signed-off-by: Sebastiaan van Stijn <github@gone.nl> (cherry picked from commit a76ff63) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 22f6cfd commit 2d3475b

1 file changed

Lines changed: 62 additions & 39 deletions

File tree

Jenkinsfile

Lines changed: 62 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,15 @@ pipeline {
109109
docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
110110
'''
111111

112-
sh '''
113-
echo 'Creating docker-py-bundles.tar.gz'
114-
tar -czf docker-py-bundles.tar.gz bundles/test-docker-py/*.xml bundles/test-docker-py/*.log
115-
'''
116-
117-
archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
112+
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
113+
sh '''
114+
bundleName=docker-py
115+
echo "Creating ${bundleName}-bundles.tar.gz"
116+
tar -czf ${bundleName}-bundles.tar.gz bundles/test-docker-py/*.xml bundles/test-docker-py/*.log
117+
'''
118+
119+
archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
120+
}
118121
}
119122
}
120123
}
@@ -200,12 +203,15 @@ pipeline {
200203
docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
201204
'''
202205

203-
sh '''
204-
echo 'Creating unit-bundles.tar.gz'
205-
tar -czvf unit-bundles.tar.gz bundles/junit-report.xml bundles/go-test-report.json bundles/profile.out
206-
'''
206+
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
207+
sh '''
208+
bundleName=unit
209+
echo "Creating ${bundleName}-bundles.tar.gz"
210+
tar -czvf ${bundleName}-bundles.tar.gz bundles/junit-report.xml bundles/go-test-report.json bundles/profile.out
211+
'''
207212

208-
archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
213+
archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
214+
}
209215
}
210216
cleanup {
211217
sh 'make clean'
@@ -317,13 +323,16 @@ pipeline {
317323
docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
318324
'''
319325

320-
sh '''
321-
echo "Creating janky-bundles.tar.gz"
322-
# exclude overlay2 directories
323-
find bundles -path '*/root/*overlay2' -prune -o -type f \\( -name '*.log' -o -name '*.prof' \\) -print | xargs tar -czf janky-bundles.tar.gz
324-
'''
326+
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
327+
sh '''
328+
bundleName=janky
329+
echo "Creating ${bundleName}-bundles.tar.gz"
330+
# exclude overlay2 directories
331+
find bundles -path '*/root/*overlay2' -prune -o -type f \\( -o -name '*.log' -o -name '*.prof' \\) -print | xargs tar -czf ${bundleName}-bundles.tar.gz
332+
'''
325333

326-
archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
334+
archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
335+
}
327336
}
328337
cleanup {
329338
sh 'make clean'
@@ -411,13 +420,16 @@ pipeline {
411420
docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
412421
'''
413422

414-
sh '''
415-
echo "Creating s390x-integration-bundles.tar.gz"
416-
# exclude overlay2 directories
417-
find bundles -path '*/root/*overlay2' -prune -o -type f \\( -name '*.log' -o -name '*.prof' \\) -print | xargs tar -czf s390x-integration-bundles.tar.gz
418-
'''
423+
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
424+
sh '''
425+
bundleName=s390x-integration
426+
echo "Creating ${bundleName}-bundles.tar.gz"
427+
# exclude overlay2 directories
428+
find bundles -path '*/root/*overlay2' -prune -o -type f \\( -o -name '*.log' -o -name '*.prof' \\) -print | xargs tar -czf ${bundleName}-bundles.tar.gz
429+
'''
419430

420-
archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
431+
archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
432+
}
421433
}
422434
cleanup {
423435
sh 'make clean'
@@ -486,12 +498,16 @@ pipeline {
486498
docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
487499
'''
488500

489-
sh '''
490-
echo "Creating s390x-integration-cli-bundles.tar.gz"
491-
find bundles -path '*/root/*overlay2' -prune -o -type f \\( -name '*.log' -o -name '*.prof' \\) -print | xargs tar -czf s390x-integration-cli-bundles.tar.gz
492-
'''
501+
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
502+
sh '''
503+
bundleName=s390x-integration-cli
504+
echo "Creating ${bundleName}-bundles.tar.gz"
505+
# exclude overlay2 directories
506+
find bundles -path '*/root/*overlay2' -prune -o -type f \\( -o -name '*.log' -o -name '*.prof' \\) -print | xargs tar -czf ${bundleName}-bundles.tar.gz
507+
'''
493508

494-
archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
509+
archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
510+
}
495511
}
496512
cleanup {
497513
sh 'make clean'
@@ -577,13 +593,16 @@ pipeline {
577593
docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
578594
'''
579595

580-
sh '''
581-
echo "Creating powerpc-integration-bundles.tar.gz"
582-
# exclude overlay2 directories
583-
find bundles -path '*/root/*overlay2' -prune -o -type f \\( -name '*.log' -o -name '*.prof' \\) -print | xargs tar -czf powerpc-integration-bundles.tar.gz
584-
'''
596+
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
597+
sh '''
598+
bundleName=powerpc-integration
599+
echo "Creating ${bundleName}-bundles.tar.gz"
600+
# exclude overlay2 directories
601+
find bundles -path '*/root/*overlay2' -prune -o -type f \\( -o -name '*.log' -o -name '*.prof' \\) -print | xargs tar -czf ${bundleName}-bundles.tar.gz
602+
'''
585603

586-
archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
604+
archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
605+
}
587606
}
588607
cleanup {
589608
sh 'make clean'
@@ -650,12 +669,16 @@ pipeline {
650669
docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
651670
'''
652671

653-
sh '''
654-
echo "Creating powerpc-integration-cli-bundles.tar.gz"
655-
find bundles -path '*/root/*overlay2' -prune -o -type f \\( -name '*.log' -o -name '*.prof' \\) -print | xargs tar -czf powerpc-integration-cli-bundles.tar.gz
656-
'''
672+
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
673+
sh '''
674+
bundleName=powerpc-integration-cli
675+
echo "Creating ${bundleName}-bundles.tar.gz"
676+
# exclude overlay2 directories
677+
find bundles -path '*/root/*overlay2' -prune -o -type f \\( -o -name '*.log' -o -name '*.prof' \\) -print | xargs tar -czf ${bundleName}-bundles.tar.gz
678+
'''
657679

658-
archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
680+
archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
681+
}
659682
}
660683
cleanup {
661684
sh 'make clean'

0 commit comments

Comments
 (0)