diff --git a/Jenkinsfile b/Jenkinsfile index 3805972..4ae5cee 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,7 +5,7 @@ import org.yaml.snakeyaml.Yaml def (options, maven_local_repo_path, maven_settings_file, maven_parent_file) = ['', '', '', ''] def agent_root_folder = '/var/lib/jenkins/.m2' def verbose = true -def resume = ${params.resume} + if (params.Type == 'SNAPSHOT-DRY-RUN') { echo "Configure Maven for SNAPSHOT-DRY-RUN artifacts" options = '' @@ -47,7 +47,6 @@ echo "Use local repo at ${maven_local_repo_path}" echo "Release number: ${params.gCube_release_version}" echo "Clean up gcube local artifacts? ${params.cleanup_gcube_artifacts}" echo "Clean up all local artifacts? ${params.cleanup_local_repo}" -echo "Resume from previous build? ${params.resume}" //locate the release file @@ -91,10 +90,6 @@ pipeline { GCUBE_RELEASE_NUMBER = "${params.gCube_release_version}" PIPELINE_BUILD_NUMBER = "${env.BUILD_NUMBER}" 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 @@ -114,10 +109,6 @@ pipeline { booleanParam(name: 'cleanup_local_repo', defaultValue: true, 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 @@ -139,38 +130,23 @@ pipeline { 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" echo "Done with local repository and settings" - - #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 - - #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 stage('build maven-parent') { steps { - script { - if ( ("${resume}" == 'true') && (wasSuccess('maven-parent')) ) { - // propagate success - sh "echo -e \\\"maven-parent,SUCCESS\\\">> $JOB_REPORT" - } else { - def gjob = build(job: 'maven-parent', wait: true, propagate: true, - 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" - } - } + echo build(job: 'maven-parent', wait: true, + 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']] + ]).result + echo "Done with maven-parent" } } stage('build components') { @@ -179,7 +155,7 @@ pipeline { jsonConfig.gCube_release.Components.each { group_name, component_list -> stage("build ${group_name} components") { 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" } } @@ -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) { parallel args.items?.collectEntries { name -> ["${name}": { - if (name && !"NONE".equalsIgnoreCase(name)) { - if ( (resume == 'true') && (wasSuccess(name)) ) { - // propagate success - sh "echo -e \\\"${name},SUCCESS\\\">> $JOB_REPORT" - } else { - 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()}" - } - } - }] + if (name && !"NONE".equalsIgnoreCase(name)) + build(job: name, + 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']] + ]) + } + ] } } -} -/** - 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; } \ No newline at end of file