From 913b695073572869c941f81d1d7c8def9b7b62a6 Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sat, 13 Nov 2021 15:59:22 -0300 Subject: [PATCH] Move Jenkins post-build tasks to a post{} block --- .ci/Jenkinsfile | 59 ++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index e97830f05..f6f0f11f1 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -51,7 +51,7 @@ def saveArtifacts() { def anySuccess = false pipeline { - agent any + agent none parameters { string(name: 'BUILD_TYPE', @@ -94,42 +94,37 @@ pipeline { } } } + } - /* This stage has two tasks: - - Trigger downstream jobs if we're on the main job - - Fail this build if all build stages failed - This could be done with two stages and when{} blocks, but then they - would show up separately in the UI (unless JENKINS-44094 happens). */ - stage('Finish build') { - steps { - script { - if (env.JOB_BASE_NAME == '86Box-TestBuildPleaseIgnore') { - ["${env.JOB_BASE_NAME}2"].each { - try { - /* Set next build number for this job. */ - def job = Jenkins.instance.getItem(it) - job.nextBuildNumber = env.BUILD_NUMBER as Integer - job.saveNextBuildNumber() - } catch (Exception e) { - println "[!] Could not set next build number for [$it], make sure all the script approvals are in place" - } - - /* Trigger this job. */ - build propagate: false, - wait: false, - job: it, - parameters: [ - string(name: 'BUILD_TYPE', value: BUILD_TYPE), - string(name: 'BRANCH', value: env.GIT_COMMIT) - ] + post { + always { + script { + if (env.JOB_BASE_NAME == '86Box-TestBuildPleaseIgnore') { + ["${env.JOB_BASE_NAME}2"].each { + try { + /* Set next build number for this job. */ + def job = Jenkins.instance.getItem(it) + job.nextBuildNumber = env.BUILD_NUMBER as Integer + job.saveNextBuildNumber() + } catch (Exception e) { + println "[!] Could not set next build number for [$it], make sure all the script approvals are in place" } - } - if (!anySuccess) { - println "[!] Failing build because all build stages failed" - currentBuild.result = 'FAILURE' + /* Trigger this job. */ + build propagate: false, + wait: false, + job: it, + parameters: [ + string(name: 'BUILD_TYPE', value: BUILD_TYPE), + string(name: 'BRANCH', value: env.GIT_COMMIT) + ] } } + + if (!anySuccess) { + println "[!] Failing build because all build stages failed" + currentBuild.result = 'FAILURE' + } } } }