diff --git a/Jenkinsfile b/Jenkinsfile index 4ae5cee..9b2a084 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -130,11 +130,18 @@ 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}" > ${AGENT_ROOT_FOLDER}/build_jobs.${PIPELINE_BUILD_NUMBER}.csv + echo "#StartTime ${date}" >> ${AGENT_ROOT_FOLDER}/build_jobs.${PIPELINE_BUILD_NUMBER}.csv + echo -e "JobName,Status" >> ${AGENT_ROOT_FOLDER}/build_jobs.${PIPELINE_BUILD_NUMBER}.csv ''' } } @@ -203,13 +210,26 @@ def buildComponents(args, maven_settings_file, maven_local_repo_path) { parallel args.items?.collectEntries { name -> ["${name}": { if (name && !"NONE".equalsIgnoreCase(name)) - build(job: name, + def job = 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']] ]) - } - ] + echo -e "${name},${job.getResult()}" >> ${AGENT_ROOT_FOLDER}/build_jobs.${PIPELINE_BUILD_NUMBER}.csv + }] } } +} +/** + Check if the job was successfully completed in teh given report. +*/ +@NonCPS +boolean wasSuccess(report, job_name) { + "${text}".splitEachLine(',') { columns -> + if (columns[0].startsWith('#') || columns[0].startsWith('JobName')) + return + echo "NAME: columns[0] STATUS: columns[1]" + + } + false; } \ No newline at end of file