diff --git a/Jenkinsfile b/Jenkinsfile index 4495a40..0a75f05 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -80,6 +80,7 @@ pipeline { REMOVE_LOCAL_REPO = "${params.cleanup_local_repo}" GCUBE_RELEASE_NUMBER = "${params.gCube_release_version}" PIPELINE_BUILD_NUMBER = "${env.BUILD_NUMBER}" + TYPE = "${params.Type}" } // see https://jenkins.io/doc/book/pipeline/syntax/#parameters @@ -120,6 +121,11 @@ 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" + 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,Branch,Build Number,Distribution URL,Filename" >> ${AGENT_ROOT_FOLDER}/build_commits.csv ''' } } @@ -242,6 +248,8 @@ pipeline { script { sh ''' mv "${AGENT_ROOT_FOLDER}/settings.${PIPELINE_BUILD_NUMBER}" "${AGENT_ROOT_FOLDER}/settings.xml" + mv ${AGENT_ROOT_FOLDER}/build_commits.csv ${AGENT_ROOT_FOLDER}/build_commits.${PIPELINE_BUILD_NUMBER}.csv + cp ${AGENT_ROOT_FOLDER}/build_commits.${PIPELINE_BUILD_NUMBER}.csv . ''' } echo 'The default maven settings have been restored' @@ -249,13 +257,18 @@ pipeline { } success { echo 'The pipeline worked!' - mail to: 'jenkinsbuilds@d4science.org', + emailext to: 'jenkinsbuilds@d4science.org', subject: "[Jenkins build D4S] build ${currentBuild.fullDisplayName} worked", body: "Build time: ${currentBuild.durationString}. See ${env.BUILD_URL}" + emailext attachmentsPattern: "**/*.${PIPELINE_BUILD_NUMBER}.csv", + to: 'jenkinsreleases@d4science.org', + subject: "${TYPE} report for release ${GCUBE_RELEASE_NUMBER} (build #${PIPELINE_BUILD_NUMBER})", + body: "${currentBuild.fullDisplayName}. Build time: ${currentBuild.durationString}. See ${env.BUILD_URL}" } failure { echo 'The pipeline has failed' - mail to: 'jenkinsbuilds@d4science.org', + emailext attachLog: true, + to: 'jenkinsbuilds@d4science.org', subject: "[Jenkins build D4S] build ${currentBuild.fullDisplayName} failed", body: "Something is wrong with ${env.BUILD_URL}" } diff --git a/README.md b/README.md index b1ddcea..b329935 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,8 @@ Jenkins Pipeline script to manage a complete gCube release. * [Pipeline: Maven](https://plugins.jenkins.io/pipeline-maven) * [Pipeline: Basic Steps](https://plugins.jenkins.io/workflow-basic-steps) * [Kubernetes](https://plugins.jenkins.io/kubernetes) (for the YAML parser) -* [NodeLabelParameter](https://plugins.jenkins.io/nodelabelparameter) (The node and label parameter plugin allows to dynamically select the node on which a job should be executed.) +* [NodeLabelParameter](https://plugins.jenkins.io/nodelabelparameter) (to allow to dynamically select the node on which a job should be executed) +* [Email Extension](https://plugins.jenkins.io/email-ext) (to send emails with attachments) * Jenkins configured with a JDK global tool named 'OpenJDK 8' * Jenkins configured with a Maven global tool named 'Maven 3.6.2' * One or more Jenkins agents labeled as 'CD'