diff --git a/pipelines/build/common/openjdk_build_pipeline.groovy b/pipelines/build/common/openjdk_build_pipeline.groovy index 886b666c6..ed9739619 100644 --- a/pipelines/build/common/openjdk_build_pipeline.groovy +++ b/pipelines/build/common/openjdk_build_pipeline.groovy @@ -311,6 +311,21 @@ class Build { return jdkRepo } + + /* + If the given result is not SUCCESS then set the current stage result and build result accordingly + */ + def setStageResult(String stage, String result) { + if (result != "SUCCESS") { + // Use catchError to issue error message and set build & stage result + context.catchError(buildResult: result, stageResult: result) { + context.error("${stage} not successful, setting stage result to: "+result) + } + } else { + context.println "${stage} result was SUCCESS" + } + } + /* Run smoke tests, which should block the running of downstream test jobs if there are failures. If a test job that doesn't exist, it will be created dynamically. @@ -355,8 +370,9 @@ class Build { context.string(name: 'VENDOR_TEST_REPOS', value: vendorTestRepos), context.string(name: 'VENDOR_TEST_BRANCHES', value: vendorTestBranches), context.string(name: 'TIME_LIMIT', value: '1') - ] + ] currentBuild.result = testJob.getResult() + setStageResult("smoke test", testJob.getResult()) return testJob.getResult() } } catch (Exception e) { @@ -474,7 +490,7 @@ class Build { } } - def testJobParams = [ + def testJobParams = [ context.string(name: 'UPSTREAM_JOB_NUMBER', value: "${env.BUILD_NUMBER}"), context.string(name: 'UPSTREAM_JOB_NAME', value: "${env.JOB_NAME}"), context.string(name: 'SDK_RESOURCE', value: 'upstream'), @@ -507,6 +523,7 @@ class Build { parameters: testJobParams, wait: true currentBuild.result = testJob.getResult() + setStageResult("${testType}", testJob.getResult()) context.node('worker') { //Copy Taps files from downstream test jobs if files available. context.sh 'rm -f workspace/target/AQAvitTaps/*.tap' @@ -530,6 +547,7 @@ class Build { } } catch (Exception e) { context.println "Failed to execute test: ${e.message}" + currentBuild.result = 'FAILURE' } } return testStages @@ -896,6 +914,7 @@ class Build { } catch (e) { context.println("Failed to build ${buildConfig.TARGET_OS} installer ${e}") currentBuild.result = 'FAILURE' + setStageResult("installer", 'FAILURE') } } } @@ -922,6 +941,7 @@ class Build { } catch (e) { context.println("Failed to build ${buildConfig.TARGET_OS} installer ${e}") currentBuild.result = 'FAILURE' + setStageResult("sign installer", 'FAILURE') } } } @@ -961,6 +981,7 @@ class Build { // For Windows and Mac verify that all necessary executables are Signed and Notarized(mac) private void verifySigning() { if (buildConfig.TARGET_OS == "windows" || buildConfig.TARGET_OS == "mac") { + context.stage('sign verification') { try { context.println "RUNNING sign_verification for ${buildConfig.TARGET_OS}/${buildConfig.ARCHITECTURE} ..." @@ -990,7 +1011,9 @@ class Build { } catch (e) { context.println("Failed to sign_verification for ${buildConfig.TARGET_OS}/${buildConfig.ARCHITECTURE} ${e}") currentBuild.result = 'FAILURE' - } + setStageResult("sign verification", 'FAILURE') + } + } } } @@ -2181,6 +2204,7 @@ class Build { } } catch (Exception e) { context.println(e.message) + currentBuild.result = 'FAILURE' } } @@ -2199,6 +2223,7 @@ class Build { gpgSign() } catch (Exception e) { context.println(e.message) + currentBuild.result = 'FAILURE' } } @@ -2209,6 +2234,7 @@ class Build { verifySigning() } catch (Exception e) { context.println(e.message) + currentBuild.result = 'FAILURE' } } }