From 805862f55db250d3f06622b71255c44686356a46 Mon Sep 17 00:00:00 2001 From: Manuele Simi Date: Thu, 12 Dec 2019 22:50:53 -0500 Subject: [PATCH] Append new commits to the previous commit report. --- Jenkinsfile | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 12a0be3..86a6108 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -72,7 +72,9 @@ if (verbose) { def jobs = [:] def previous_report_content = '' -def previous_report_file = "${agent_root_folder}/build_jobs.${resume_from}.csv" +def previous_report_file = "${agent_root_folder}/build_jobs.${resume}.csv" +def previous_commit_file = "${agent_root_folder}/build_commits.${resume}.csv" + pipeline { @@ -98,6 +100,7 @@ pipeline { RESUME = "${params.resume}" JOB_REPORT = "${agent_root_folder}/build_jobs.${env.BUILD_NUMBER}.csv" PREVIOUS_JOB_REPORT = "${previous_report_file}" + PREVIOUS_COMMIT_REPORT = "${previous_commit_file}" } // see https://jenkins.io/doc/book/pipeline/syntax/#parameters @@ -132,23 +135,27 @@ pipeline { content = readFile("${previous_report_file}") println "JOB REPORT CONTENT: ${content}" jobs = parseJobs(content) - sh "cp ${PREVIOUS_JOB_REPORT} ${JOB_REPORT}" - } else { - sh "echo #Build ${PIPELINE_BUILD_NUMBER} > ${JOB_REPORT}" - sh "echo #StartTime ${date} >> ${JOB_REPORT}" - sh "echo -e JobName,Status >> ${JOB_REPORT}" + sh "rm ${AGENT_ROOT_FOLDER}/build_commits.csv" + sh "cp ${PREVIOUS_COMMIT_REPORT} ${AGENT_ROOT_FOLDER}/build_commits.csv" } } - sh ''' - #build report - echo "#Build ${PIPELINE_BUILD_NUMBER}" > ${AGENT_ROOT_FOLDER}/build_commits.csv - echo "#Release ${GCUBE_RELEASE_NUMBER}" >> ${AGENT_ROOT_FOLDER}/build_commits.csv - date=`date` - echo "#StartTime ${date}" >> ${AGENT_ROOT_FOLDER}/build_commits.csv - echo -e "GroupID,ArtifactID,Version,SCM URL,Build Number,Distribution URL,Filename,Packaging" >> ${AGENT_ROOT_FOLDER}/build_commits.csv + sh ''' + # job report + echo ""#Build ${PIPELINE_BUILD_NUMBER}" > ${JOB_REPORT} + echo "#StartTime ${date}" >> ${JOB_REPORT} + echo -e "JobName,Status" >> ${JOB_REPORT} - ''' + # create build report if not resumed + if [ ! -f ${AGENT_ROOT_FOLDER}/build_commits.csv ]; then + #build report + echo "#Build ${PIPELINE_BUILD_NUMBER}" > ${AGENT_ROOT_FOLDER}/build_commits.csv + echo "#Release ${GCUBE_RELEASE_NUMBER}" >> ${AGENT_ROOT_FOLDER}/build_commits.csv + date=`date` + echo "#StartTime ${date}" >> ${AGENT_ROOT_FOLDER}/build_commits.csv + echo -e "GroupID,ArtifactID,Version,SCM URL,Build Number,Distribution URL,Filename,Packaging" >> ${AGENT_ROOT_FOLDER}/build_commits.csv + fi + ''' } } stage('initialize local repository') { @@ -186,7 +193,6 @@ pipeline { [$class: 'StringParameterValue', name: 'local_repo', value: "${maven_local_repo_path}"], [$class: 'LabelParameterValue', name: 'exec_label', label: "CD", nodeEligibility: [$class: 'AllNodeEligibility']] ]) - echo "Job report file: ${agent_root_folder}/build_jobs.${env.BUILD_NUMBER}.csv" sh "echo -e maven-parent,${gjob.getResult()} >> ${agent_root_folder}/build_jobs.${env.BUILD_NUMBER}.csv" echo "Done with maven-parent" } @@ -259,7 +265,6 @@ def buildComponents(args, maven_settings_file, maven_local_repo_path, jobs) { [$class: 'StringParameterValue', name: 'local_repo', value: "${maven_local_repo_path}"], [$class: 'LabelParameterValue', name: 'exec_label', label: "CD", nodeEligibility: [$class: 'AllNodeEligibility']] ]) - echo "Job report file: ${agent_root_folder}/build_jobs.${env.BUILD_NUMBER}.csv" sh "echo -e ${name},${gjob.getResult()} >> ${agent_root_folder}/build_jobs.${env.BUILD_NUMBER}.csv" } }