Restore jenkins file.
This commit is contained in:
parent
c5216cebda
commit
f19fb497fb
|
@ -5,7 +5,7 @@ import org.yaml.snakeyaml.Yaml
|
||||||
def (options, maven_local_repo_path, maven_settings_file, maven_parent_file) = ['', '', '', '']
|
def (options, maven_local_repo_path, maven_settings_file, maven_parent_file) = ['', '', '', '']
|
||||||
def agent_root_folder = '/var/lib/jenkins/.m2'
|
def agent_root_folder = '/var/lib/jenkins/.m2'
|
||||||
def verbose = true
|
def verbose = true
|
||||||
def resume = ${params.resume}
|
|
||||||
if (params.Type == 'SNAPSHOT-DRY-RUN') {
|
if (params.Type == 'SNAPSHOT-DRY-RUN') {
|
||||||
echo "Configure Maven for SNAPSHOT-DRY-RUN artifacts"
|
echo "Configure Maven for SNAPSHOT-DRY-RUN artifacts"
|
||||||
options = ''
|
options = ''
|
||||||
|
@ -47,7 +47,6 @@ echo "Use local repo at ${maven_local_repo_path}"
|
||||||
echo "Release number: ${params.gCube_release_version}"
|
echo "Release number: ${params.gCube_release_version}"
|
||||||
echo "Clean up gcube local artifacts? ${params.cleanup_gcube_artifacts}"
|
echo "Clean up gcube local artifacts? ${params.cleanup_gcube_artifacts}"
|
||||||
echo "Clean up all local artifacts? ${params.cleanup_local_repo}"
|
echo "Clean up all local artifacts? ${params.cleanup_local_repo}"
|
||||||
echo "Resume from previous build? ${params.resume}"
|
|
||||||
|
|
||||||
|
|
||||||
//locate the release file
|
//locate the release file
|
||||||
|
@ -91,10 +90,6 @@ 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}"
|
||||||
RESUME = "${params.resume}"
|
|
||||||
JOB_REPORT = "${agent_root_folder}/build_jobs.${env.BUILD_NUMBER}.csv"
|
|
||||||
PREVIOUS_JOB_REPORT = "${agent_root_folder}/build_jobs.${env.BUILD_NUMBER -1}.csv"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// see https://jenkins.io/doc/book/pipeline/syntax/#parameters
|
// see https://jenkins.io/doc/book/pipeline/syntax/#parameters
|
||||||
|
@ -114,10 +109,6 @@ 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,38 +130,23 @@ pipeline {
|
||||||
mv "${AGENT_ROOT_FOLDER}/settings.xml" "${AGENT_ROOT_FOLDER}/settings.${PIPELINE_BUILD_NUMBER}"
|
mv "${AGENT_ROOT_FOLDER}/settings.xml" "${AGENT_ROOT_FOLDER}/settings.${PIPELINE_BUILD_NUMBER}"
|
||||||
cp "${AGENT_ROOT_FOLDER}/${MAVEN_SETTINGS_FILE}" "${AGENT_ROOT_FOLDER}/settings.xml"
|
cp "${AGENT_ROOT_FOLDER}/${MAVEN_SETTINGS_FILE}" "${AGENT_ROOT_FOLDER}/settings.xml"
|
||||||
echo "Done with local repository and settings"
|
echo "Done with local repository and settings"
|
||||||
|
|
||||||
#build report
|
|
||||||
echo "#Build ${PIPELINE_BUILD_NUMBER}" > ${AGENT_ROOT_FOLDER}/build_commits.csv
|
echo "#Build ${PIPELINE_BUILD_NUMBER}" > ${AGENT_ROOT_FOLDER}/build_commits.csv
|
||||||
echo "#Release ${GCUBE_RELEASE_NUMBER}" >> ${AGENT_ROOT_FOLDER}/build_commits.csv
|
echo "#Release ${GCUBE_RELEASE_NUMBER}" >> ${AGENT_ROOT_FOLDER}/build_commits.csv
|
||||||
date=`date`
|
date=`date`
|
||||||
echo "#StartTime ${date}" >> ${AGENT_ROOT_FOLDER}/build_commits.csv
|
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
|
echo -e "GroupID,ArtifactID,Version,SCM URL,Build Number,Distribution URL,Filename,Packaging" >> ${AGENT_ROOT_FOLDER}/build_commits.csv
|
||||||
|
|
||||||
#job report
|
|
||||||
echo "#Build ${PIPELINE_BUILD_NUMBER}" > $JOB_REPORT
|
|
||||||
echo "#StartTime ${date}" >> $JOB_REPORT
|
|
||||||
echo -e "JobName,Status" >> $JOB_REPORT
|
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// the maven-parent needs to be built (once) at each execution
|
// the maven-parent needs to be built (once) at each execution
|
||||||
stage('build maven-parent') {
|
stage('build maven-parent') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
echo build(job: 'maven-parent', wait: true,
|
||||||
if ( ("${resume}" == 'true') && (wasSuccess('maven-parent')) ) {
|
parameters: [[$class: 'StringParameterValue', name: 'gcube_settings', value: "${maven_parent_file}"],
|
||||||
// propagate success
|
[$class: 'StringParameterValue', name: 'local_repo', value: "${maven_local_repo_path}"],
|
||||||
sh "echo -e \\\"maven-parent,SUCCESS\\\">> $JOB_REPORT"
|
[$class: 'LabelParameterValue', name: 'exec_label', label: "CD", nodeEligibility: [$class: 'AllNodeEligibility']]
|
||||||
} else {
|
]).result
|
||||||
def gjob = build(job: 'maven-parent', wait: true, propagate: true,
|
echo "Done with maven-parent"
|
||||||
parameters: [[$class: 'StringParameterValue', name: 'gcube_settings', value: "${maven_parent_file}"],
|
|
||||||
[$class: 'StringParameterValue', name: 'local_repo', value: "${maven_local_repo_path}"],
|
|
||||||
[$class: 'LabelParameterValue', name: 'exec_label', label: "CD", nodeEligibility: [$class: 'AllNodeEligibility']]
|
|
||||||
])
|
|
||||||
sh "echo -e \\\"maven-parent,${gjob.getResult()}\\\">> $JOB_REPORT"
|
|
||||||
echo "Done with maven-parent"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('build components') {
|
stage('build components') {
|
||||||
|
@ -179,7 +155,7 @@ pipeline {
|
||||||
jsonConfig.gCube_release.Components.each { group_name, component_list ->
|
jsonConfig.gCube_release.Components.each { group_name, component_list ->
|
||||||
stage("build ${group_name} components") {
|
stage("build ${group_name} components") {
|
||||||
buildComponents items: component_list?.collect { "${it.name}" },
|
buildComponents items: component_list?.collect { "${it.name}" },
|
||||||
"${maven_settings_file}", "${maven_local_repo_path}", "${resume}"
|
"${maven_settings_file}", "${maven_local_repo_path}"
|
||||||
echo "Done with ${group_name} components"
|
echo "Done with ${group_name} components"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,40 +198,18 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def buildComponents(args, maven_settings_file, maven_local_repo_path, resume) {
|
def buildComponents(args, maven_settings_file, maven_local_repo_path) {
|
||||||
if (args.items) {
|
if (args.items) {
|
||||||
parallel args.items?.collectEntries { name ->
|
parallel args.items?.collectEntries { name ->
|
||||||
["${name}": {
|
["${name}": {
|
||||||
if (name && !"NONE".equalsIgnoreCase(name)) {
|
if (name && !"NONE".equalsIgnoreCase(name))
|
||||||
if ( (resume == 'true') && (wasSuccess(name)) ) {
|
build(job: name,
|
||||||
// propagate success
|
parameters: [[$class: 'StringParameterValue', name: 'gcube_settings', value: "${maven_settings_file}"],
|
||||||
sh "echo -e \\\"${name},SUCCESS\\\">> $JOB_REPORT"
|
[$class: 'StringParameterValue', name: 'local_repo', value: "${maven_local_repo_path}"],
|
||||||
} else {
|
[$class: 'LabelParameterValue', name: 'exec_label', label: "CD", nodeEligibility: [$class: 'AllNodeEligibility']]
|
||||||
def gjob = build job: name, propagate: true, wait: true,
|
])
|
||||||
parameters: [[$class: 'StringParameterValue', name: 'gcube_settings', value: "${maven_settings_file}"],
|
}
|
||||||
[$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()}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
/**
|
|
||||||
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.equals(columns[0]) && columns[1].equal('SUCCESS')) {
|
|
||||||
ret = true
|
|
||||||
println "NAME: ${columns[0]} STATUS: ${columns[1]}"
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ret;
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue