diff --git a/jobs/Jenkinsfile_BuildAll b/jobs/Jenkinsfile_BuildAll index 9571611..db9ea77 100644 --- a/jobs/Jenkinsfile_BuildAll +++ b/jobs/Jenkinsfile_BuildAll @@ -134,7 +134,7 @@ def runUpdateSrcRevJob(commonHelpers, buildBranch, isCleanRequested, isDryRun) { try { updateJob = build(job: "${env.SRCREV_JOB}", quietPeriod: 0, - propagate: true, + propagate: false, wait: true, parameters: [string(name: 'BUILD_BRANCH', value: buildBranch), booleanParam(name: 'CLEAN_BUILD', value: isCleanRequested), @@ -143,7 +143,6 @@ def runUpdateSrcRevJob(commonHelpers, buildBranch, isCleanRequested, isDryRun) { } catch(Exception e) { error("Exception: " + e.toString()) - return } // assert to be sure if(updateJob == null) { @@ -181,11 +180,12 @@ def isMachineSane(machine) { //----------------------------------------------------------------------------- def runBuildJob(commonHelpers, buildTarget, buildBranch) { def buildJob = null - Boolean isSuccessfullyBuilt = true + def theBuildResult = 'SUCCESS' + Boolean hasException = false try { buildJob = build(job: "${env.BUILD_JOB}", quietPeriod: 0, - propagate: true, + propagate: false, wait: true, parameters: [string(name: 'TARGET', value: buildTarget), string(name: 'BUILD_BRANCH', value: buildBranch), @@ -196,17 +196,26 @@ def runBuildJob(commonHelpers, buildTarget, buildBranch) { booleanParam(name: 'DEBUGGING', value: params.DEBUGGING)] ) } + catch (org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e) { + println "job ${env.BUILD_JOB} for TARGET=${buildTarget} was cancelled or aborted" + theBuildResult = 'ABORTED' + } catch(Exception e) { - error("Exception: " + e.toString()) - return + hasException = true + theBuildResult = 'FAILURE' + println "Exception caught: " + e.toString() + } + finally { + if(!hasException && (buildJob != null)) { + theBuildResult = buildJob.getResult() + } + return theBuildResult } // assert to be sure if(buildJob == null) { error("Something went really wrong with ${env.BUILD_JOB} (TARGET=${buildTarget})") - return } - isSuccessfullyBuilt = (buildJob.getResult() == 'SUCCESS') - return isSuccessfullyBuilt + return buildJob.getResult() } //----------------------------------------------------------------------------- def buildMachine(commonHelpers, machine, buildBranch) { @@ -215,7 +224,13 @@ def buildMachine(commonHelpers, machine, buildBranch) { // NOTE: this catchError statement is needed in case of an // abort of the build job or similar failures catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') { - isMachineSuccessfullyBuilt = runBuildJob(commonHelpers, machine, buildBranch) + def buildJobStatus = runBuildJob(commonHelpers, machine, buildBranch) + if(buildJobStatus != 'SUCCESS') { + isMachineSuccessfullyBuilt = false + if(buildJobStatus == 'ABORTED') { + currentBuild.result = 'ABORTED' + } + } } if(!isMachineSuccessfullyBuilt) { println "Failed building properly machine ${machine}" @@ -231,7 +246,7 @@ def buildAllTargets(commonHelpers, buildBranch) { catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') { for (machine in listOfTargets) { - if(isMachineSane(machine)) { + if(!commonHelpers.isCurrentJobAborted() && isMachineSane(machine)) { Boolean isMachineSuccess = buildMachine(commonHelpers, machine, buildBranch) if(!isMachineSuccess && areBuildsSuccessful) { areBuildsSuccessful = false @@ -245,5 +260,4 @@ def buildAllTargets(commonHelpers, buildBranch) { error("Failing build - first machine failing = ${firstMachineFailing}") } } // end catchError - commonHelpers.cleanupRepository("${env.YOCTO_REPO_DIR}") } \ No newline at end of file diff --git a/jobs/Jenkinsfile_Common b/jobs/Jenkinsfile_Common index caf0fbf..cbb21c5 100644 --- a/jobs/Jenkinsfile_Common +++ b/jobs/Jenkinsfile_Common @@ -74,6 +74,10 @@ def isCurrentJobSuccess() { return (currentBuild.currentResult == 'SUCCESS') } //----------------------------------------------------------------------------- +def isCurrentJobAborted() { + return ((currentBuild.currentResult == 'ABORTED') || (currentBuild.result == 'ABORTED')) +} +//----------------------------------------------------------------------------- def cleaningClonedRepoDir() { println "cleaning the entire repository..." sh("git clean -ffdx")