Parse the previous report and decide what to build.
This commit is contained in:
parent
481a58150f
commit
1ca7b3d462
|
@ -90,6 +90,9 @@ pipeline {
|
||||||
GCUBE_RELEASE_NUMBER = "${params.gCube_release_version}"
|
GCUBE_RELEASE_NUMBER = "${params.gCube_release_version}"
|
||||||
PIPELINE_BUILD_NUMBER = "${env.BUILD_NUMBER}"
|
PIPELINE_BUILD_NUMBER = "${env.BUILD_NUMBER}"
|
||||||
TYPE = "${params.Type}"
|
TYPE = "${params.Type}"
|
||||||
|
JOB_REPORT = "${AGENT_ROOT_FOLDER}/build_jobs.${PIPELINE_BUILD_NUMBER}.csv"
|
||||||
|
PREVIOUS_JOB_REPORT = "${AGENT_ROOT_FOLDER}/build_jobs.${PIPELINE_BUILD_NUMBER -1}.csv"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// see https://jenkins.io/doc/book/pipeline/syntax/#parameters
|
// see https://jenkins.io/doc/book/pipeline/syntax/#parameters
|
||||||
|
@ -109,6 +112,10 @@ pipeline {
|
||||||
booleanParam(name: 'cleanup_local_repo',
|
booleanParam(name: 'cleanup_local_repo',
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
description: 'Wipe out the local maven repository before the builds?')
|
description: 'Wipe out the local maven repository before the builds?')
|
||||||
|
|
||||||
|
booleanParam(name: 'resume',
|
||||||
|
defaultValue: false,
|
||||||
|
description: 'Resume from previous build?')
|
||||||
}
|
}
|
||||||
|
|
||||||
//see https://jenkins.io/doc/book/pipeline/syntax/#stages
|
//see https://jenkins.io/doc/book/pipeline/syntax/#stages
|
||||||
|
@ -139,9 +146,9 @@ pipeline {
|
||||||
echo -e "GroupID,ArtifactID,Version,SCM URL,Build Number,Distribution URL,Filename,Packaging" >> ${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
|
||||||
|
|
||||||
#job report
|
#job report
|
||||||
echo "#Build ${PIPELINE_BUILD_NUMBER}" > ${AGENT_ROOT_FOLDER}/build_jobs.${PIPELINE_BUILD_NUMBER}.csv
|
echo "#Build ${PIPELINE_BUILD_NUMBER}" > $JOB_REPORT
|
||||||
echo "#StartTime ${date}" >> ${AGENT_ROOT_FOLDER}/build_jobs.${PIPELINE_BUILD_NUMBER}.csv
|
echo "#StartTime ${date}" >> $JOB_REPORT
|
||||||
echo -e "JobName,Status" >> ${AGENT_ROOT_FOLDER}/build_jobs.${PIPELINE_BUILD_NUMBER}.csv
|
echo -e "JobName,Status" >> $JOB_REPORT
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,13 +217,18 @@ def buildComponents(args, maven_settings_file, maven_local_repo_path) {
|
||||||
parallel args.items?.collectEntries { name ->
|
parallel args.items?.collectEntries { name ->
|
||||||
["${name}": {
|
["${name}": {
|
||||||
if (name && !"NONE".equalsIgnoreCase(name)) {
|
if (name && !"NONE".equalsIgnoreCase(name)) {
|
||||||
def gjob = build job: name, propagate: true, wait: true,
|
if ( (${params.resume}) && (wasSuccess(name)) {
|
||||||
parameters: [[$class: 'StringParameterValue', name: 'gcube_settings', value: "${maven_settings_file}"],
|
// propagate success
|
||||||
[$class: 'StringParameterValue', name: 'local_repo', value: "${maven_local_repo_path}"],
|
sh "echo -e \\\"${name},SUCCESS\\\">> $JOB_REPORT"
|
||||||
[$class: 'LabelParameterValue', name: 'exec_label', label: "CD", nodeEligibility: [$class: 'AllNodeEligibility']]
|
} else {
|
||||||
]
|
def gjob = build job: name, propagate: true, wait: true,
|
||||||
sh "echo -e \\\"${name},${gjob.getResult()}\\\">> ${AGENT_ROOT_FOLDER}/build_jobs.${PIPELINE_BUILD_NUMBER}.csv"
|
parameters: [[$class: 'StringParameterValue', name: 'gcube_settings', value: "${maven_settings_file}"],
|
||||||
println "job results: ${gjob.getResult()}"
|
[$class: 'StringParameterValue', name: 'local_repo', value: "${maven_local_repo_path}"],
|
||||||
|
[$class: 'LabelParameterValue', name: 'exec_label', label: "CD", nodeEligibility: [$class: 'AllNodeEligibility']]
|
||||||
|
]
|
||||||
|
sh "echo -e \\\"${name},${gjob.getResult()}\\\">> $JOB_REPORT"
|
||||||
|
println "job results: ${gjob.getResult()}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
@ -226,11 +238,14 @@ def buildComponents(args, maven_settings_file, maven_local_repo_path) {
|
||||||
Check if the job was successfully completed in teh given report.
|
Check if the job was successfully completed in teh given report.
|
||||||
*/
|
*/
|
||||||
@NonCPS
|
@NonCPS
|
||||||
boolean wasSuccess(report, job_name) {
|
boolean wasSuccess(job_name) {
|
||||||
"${text}".splitEachLine(',') { columns ->
|
boolean ret = false
|
||||||
if (columns[0].startsWith('#') || columns[0].startsWith('JobName'))
|
new File("$PREVIOUS_JOB_REPORT").splitEachLine(',') { columns ->
|
||||||
return
|
if job_name.equals(columns[0]) && columns[1].equal('SUCCESS') {
|
||||||
println "NAME: ${columns[0]} STATUS: ${columns[1]}"
|
ret = true
|
||||||
|
println "NAME: ${columns[0]} STATUS: ${columns[1]}"
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
false;
|
ret;
|
||||||
}
|
}
|
Loading…
Reference in New Issue