From 517153a3ae292641021952e439b054d5b43d92bb Mon Sep 17 00:00:00 2001 From: Manuele Simi Date: Mon, 9 Dec 2019 16:35:11 -0500 Subject: [PATCH] Parse job report before the pipeline execution. --- Jenkinsfile | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 12f1ebe..42678ea 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -70,6 +70,12 @@ if (verbose) { jsonConfig.gCube_release.Components.each { println it.key } } +def jobs = parseJobs("${agent_root_folder}/build_jobs.${env.BUILD_NUMBER -1}.csv") +for (job in jobs) { + println "$job" +} + + pipeline { // see https://jenkins.io/doc/book/pipeline/syntax/#agent @@ -157,7 +163,7 @@ pipeline { stage('build maven-parent') { steps { script { - if ( ("${resume}" == 'true') && (wasSuccess('maven-parent')) ) { + if ( ("${resume}" == 'true') && (jobs['maven-parent'] == 'SUCCESS') ) { // propagate success sh "echo -e \\\"maven-parent,SUCCESS\\\">> $JOB_REPORT" } else { @@ -242,14 +248,12 @@ 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 - } +def parseJobs(job_file) { + def jobs = [:] + new File(job_file).splitEachLine(',') { columns -> + if (columns[0].startsWith('#') || columns[0].startsWith('GroupID')) + return + jobs["${columns[0]}"] = columns[1] } - ret; + jobs; } \ No newline at end of file