Append new commits to the previous commit report.

This commit is contained in:
Manuele Simi 2019-12-12 22:50:53 -05:00
parent 0a173b49c6
commit 805862f55d
1 changed files with 21 additions and 16 deletions

37
Jenkinsfile vendored
View File

@ -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"
}
}