From 0e32ed0cc036e11083f1592cccdb01098eadbefa Mon Sep 17 00:00:00 2001 From: Etan Kissling Date: Fri, 18 Nov 2022 17:08:56 +0100 Subject: [PATCH] cancel non-started finalization testnets on cancel (#4334) When cancelling the `minimal` CI finalization testnet on Jenkins, the internal Jenkins cancellation exception is being caught by `catchError` and the `mainnet` CI finalization testnet will still run. Replacing the logic with `try` / `finally` instead, and moving the `archiveArtifacts` step to the post-build (to run that even on cancellation / failure). --- ci/Jenkinsfile | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index d68acf9e0..68fc87aad 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -77,23 +77,26 @@ pipeline { stage('Finalizations') { stages { /* parallel builds of minimal / mainnet not yet supported */ stage('minimal') { - steps { script { timeout(26) { - launchLocalTestnet('minimal') - } } } + steps { timeout(26) { + sh 'make local-testnet-minimal' + } } + post { always { + sh 'tar cjf local-testnet-minimal.tar.gz local-testnet-minimal/*.txt' + } } } stage('mainnet') { - steps { script { timeout(62) { - launchLocalTestnet('mainnet') - } } } + steps { timeout(62) { + sh 'make local-testnet-mainnet' + } } + post { always { + sh 'tar cjf local-testnet-mainnet.tar.gz local-testnet-mainnet/*.txt' + } } } } - } - - stage('Upload') { - steps { timeout(5) { - archiveArtifacts('*.tar.gz') - } } + post { always { timeout(5) { + archiveArtifacts(artifacts: '*.tar.gz', allowEmptyArchive: true) + } } } } } @@ -107,19 +110,6 @@ pipeline { } } -def launchLocalTestnet(String name) { - /* We want to mark job as failed, but save the results. */ - catchError( - message: "Local ${name} testnet finalization failure!", - buildResult: 'FAILURE', - stageResult: 'FAILURE' - ) { - sh "make local-testnet-${name}" - } - /* Archive test results regardless of outcome. */ - sh "tar cjf local-testnet-${name}.tar.gz local-testnet-${name}/*.txt" -} - def isMainBranch() { return ['stable', 'testing', 'unstable'].contains(env.BRANCH_NAME) }