add send mail as post action
This commit is contained in:
parent
c55dca78f1
commit
517fbb40f0
|
@ -10,6 +10,14 @@ pipeline {
|
||||||
agent {
|
agent {
|
||||||
label 'CD'
|
label 'CD'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
environment {
|
||||||
|
AGENT_ROOT_FOLDER = "${agent_root_folder}"
|
||||||
|
PIPELINE_BUILD_NUMBER = "${env.BUILD_NUMBER}"
|
||||||
|
WALKER_NOTES = "${agent_root_folder}/walker_notes.${pipeline_build_number}.md"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
parameters {
|
parameters {
|
||||||
string(name: 'jenkins_project',
|
string(name: 'jenkins_project',
|
||||||
defaultValue: '',
|
defaultValue: '',
|
||||||
|
@ -69,6 +77,34 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// post-build actions
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
script {
|
||||||
|
sh '''
|
||||||
|
cp $WALKER_NOTES ./walker_notes.${PIPELINE_BUILD_NUMBER}.md
|
||||||
|
cat ./$WALKER_NOTES
|
||||||
|
'''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
success {
|
||||||
|
echo 'The dependencies walker pipeline worked!'
|
||||||
|
emailext to: 'jenkinsbuilds@d4science.org',
|
||||||
|
subject: "[Jenkins WalkerPipeline D4S] build ${currentBuild.fullDisplayName} worked",
|
||||||
|
body: "Build time: ${currentBuild.durationString}. See ${env.BUILD_URL}"
|
||||||
|
emailext attachmentsPattern: "**/walker_notes.${PIPELINE_BUILD_NUMBER}.md",
|
||||||
|
to: 'jenkinsreleases@d4science.org',
|
||||||
|
subject: "Walker Dependencies for gCube component ${inputProject} (build #${PIPELINE_BUILD_NUMBER})",
|
||||||
|
body: "Release notes extracted from the CHANGELOG.md(s) of the released components. See ${env.BUILD_URL}"
|
||||||
|
}
|
||||||
|
failure {
|
||||||
|
echo 'The dependencies walker pipeline has failed'
|
||||||
|
emailext attachLog: true,
|
||||||
|
to: 'jenkinsbuilds@d4science.org',
|
||||||
|
subject: "[JenkinsDependenciesWalker D4S] build ${currentBuild.fullDisplayName} failed",
|
||||||
|
body: "Something is wrong with ${env.BUILD_URL}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// look for modules that use this artifact
|
// look for modules that use this artifact
|
||||||
|
@ -145,6 +181,42 @@ def printReport(report) {
|
||||||
}
|
}
|
||||||
println text
|
println text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// print the final report
|
||||||
|
def saveReport(report) {
|
||||||
|
def text = ''
|
||||||
|
def indent = '\t'
|
||||||
|
text += "Dependency Report for ${report['project']}"
|
||||||
|
text += "\n\n"
|
||||||
|
text += "|--Project Maven Modules\n"
|
||||||
|
report['downstream_modules'].each { depth, artifacts ->
|
||||||
|
artifacts.each { name, data ->
|
||||||
|
text += "${indent}|--Module: ${name}\n"
|
||||||
|
text += "${indent * 2}|--Deepest Dependency Level: ${depth}\n"
|
||||||
|
text += "${indent * 2}|--Used by (Maven Modules)\n"
|
||||||
|
data['dependencies'].each { d ->
|
||||||
|
text += "${indent * 3}|--${d}"
|
||||||
|
text += "\n"
|
||||||
|
}
|
||||||
|
text += "${indent * 2}|--Referred by (Jenkins Projects)\n"
|
||||||
|
data['projects'].each { p ->
|
||||||
|
text += "${indent * 3}|--${p}"
|
||||||
|
text += "\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
text += "\n\n"
|
||||||
|
text += "|--All Downstream Projects\n"
|
||||||
|
report['downstream_projects'].unique().sort()
|
||||||
|
report['downstream_projects'].each { p ->
|
||||||
|
text += "${indent}|--${p}"
|
||||||
|
text += "\n"
|
||||||
|
}
|
||||||
|
text > WALKER_NOTES
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// debug job
|
// debug job
|
||||||
def printJob(job) {
|
def printJob(job) {
|
||||||
println("fullname ${job.fullName}")
|
println("fullname ${job.fullName}")
|
||||||
|
|
Loading…
Reference in New Issue