From 54b0bb03de9ba0401af288ae1e19362b47f28147 Mon Sep 17 00:00:00 2001 From: Manuele Simi Date: Mon, 9 Dec 2019 15:49:33 -0500 Subject: [PATCH] Manage job report for maven-parent. --- Jenkinsfile | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4301b3b..b08183f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -156,12 +156,20 @@ pipeline { // the maven-parent needs to be built (once) at each execution stage('build maven-parent') { steps { - echo build(job: 'maven-parent', wait: true, - parameters: [[$class: 'StringParameterValue', name: 'gcube_settings', value: "${maven_parent_file}"], - [$class: 'StringParameterValue', name: 'local_repo', value: "${maven_local_repo_path}"], - [$class: 'LabelParameterValue', name: 'exec_label', label: "CD", nodeEligibility: [$class: 'AllNodeEligibility']] - ]).result - echo "Done with maven-parent" + script { + if ( ("${resume}" == 'true') && (wasSuccess('maven-parent')) ) { + // propagate success + sh "echo -e \\\"maven-parent,SUCCESS\\\">> $JOB_REPORT" + } else { + def gjob = build(job: 'maven-parent', wait: true, propagate: true, + parameters: [[$class: 'StringParameterValue', name: 'gcube_settings', value: "${maven_parent_file}"], + [$class: 'StringParameterValue', name: 'local_repo', value: "${maven_local_repo_path}"], + [$class: 'LabelParameterValue', name: 'exec_label', label: "CD", nodeEligibility: [$class: 'AllNodeEligibility']] + ]) + sh "echo -e \\\"maven-parent,${gjob.getResult()}\\\">> $JOB_REPORT" + echo "Done with maven-parent" + } + } } } stage('build components') { @@ -227,4 +235,20 @@ def buildComponents(args, maven_settings_file, maven_local_repo_path) { ] } } +} + +/** + Check if the job was successfully completed in teh given report. +*/ +@NonCPS +boolean wasSuccess(job_name) { + boolean ret = false + new File("${agent_root_folder}/build_jobs.${env.BUILD_NUMBER -1}.csv").splitEachLine(',') { columns -> + if (job_name.equalsIgnoreCase(columns[0]) && columns[1].equalsIgnoreCase('SUCCESS')) { + ret = true + println "NAME: ${columns[0]} STATUS: ${columns[1]}" + return + } + } + ret; } \ No newline at end of file