From 68826de75976639cbaf6ede9c4db27cfaf18c416 Mon Sep 17 00:00:00 2001 From: Manuele Simi Date: Mon, 9 Dec 2019 16:50:50 -0500 Subject: [PATCH] Calculate previous job number. --- Jenkinsfile | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 42678ea..3b7d541 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -70,12 +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") +def report_number = env.BUILD_NUMBER -1 +def jobs = parseJobs("${agent_root_folder}/build_jobs.${report_number}.csv") for (job in jobs) { println "$job" } - pipeline { // see https://jenkins.io/doc/book/pipeline/syntax/#agent @@ -250,10 +250,12 @@ def buildComponents(args, maven_settings_file, maven_local_repo_path) { @NonCPS 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] - } + try { + new File(job_file).splitEachLine(',') { columns -> + if (columns[0].startsWith('#') || columns[0].startsWith('GroupID')) + return + jobs["${columns[0]}"] = columns[1] + } + } catch() {println "Previous job report not available"} jobs; } \ No newline at end of file