Use emailext in Jenkins pipeline to notify explicit people
This commit is contained in:
parent
723735ca76
commit
45c891a75a
|
@ -192,15 +192,55 @@ stage('Build') {
|
||||||
if ( containerName != null ) {
|
if ( containerName != null ) {
|
||||||
sh "docker rm -f ${containerName}"
|
sh "docker rm -f ${containerName}"
|
||||||
}
|
}
|
||||||
if ( buildEnv.notificationRecipients != null ) {
|
// Skip this for PRs
|
||||||
notifyBuildResult(
|
if ( !env.CHANGE_ID && buildEnv.notificationRecipients != null ) {
|
||||||
maintainers: buildEnv.notificationRecipients,
|
boolean success = currentBuild.result == 'SUCCESS'
|
||||||
notifySuccessAfterSuccess: false
|
String previousResult = currentBuild.previousBuild == null ? null : currentBuild.previousBuild.result == 'SUCCESS'
|
||||||
|
|
||||||
|
// Ignore success after success
|
||||||
|
if ( !( success && previousResult == 'SUCCESS' ) ) {
|
||||||
|
def subject
|
||||||
|
def body
|
||||||
|
if ( success ) {
|
||||||
|
if ( previousResult != 'SUCCESS' && previousResult != null ) {
|
||||||
|
subject = "${env.JOB_NAME} - Build ${env.BUILD_NUMBER} - Fixed"
|
||||||
|
body = """<p>${env.JOB_NAME} - Build ${env.BUILD_NUMBER} - Fixed:</p>
|
||||||
|
<p>Check console output at <a href='${env.BUILD_URL}'>${env.BUILD_URL}</a> to view the results.</p>"""
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
subject = "${env.JOB_NAME} - Build ${env.BUILD_NUMBER} - Success"
|
||||||
|
body = """<p>${env.JOB_NAME} - Build ${env.BUILD_NUMBER} - Success:</p>
|
||||||
|
<p>Check console output at <a href='${env.BUILD_URL}'>${env.BUILD_URL}</a> to view the results.</p>"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( currentBuild.result == 'FAILURE' ) {
|
||||||
|
if ( previousResult != null && previousResult == "FAILURE" ) {
|
||||||
|
subject = "${env.JOB_NAME} - Build ${env.BUILD_NUMBER} - Still failing"
|
||||||
|
body = """<p>${env.JOB_NAME} - Build ${env.BUILD_NUMBER} - Still failing:</p>
|
||||||
|
<p>Check console output at <a href='${env.BUILD_URL}'>${env.BUILD_URL}</a> to view the results.</p>"""
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
subject = "${env.JOB_NAME} - Build ${env.BUILD_NUMBER} - Failure"
|
||||||
|
body = """<p>${env.JOB_NAME} - Build ${env.BUILD_NUMBER} - Failure:</p>
|
||||||
|
<p>Check console output at <a href='${env.BUILD_URL}'>${env.BUILD_URL}</a> to view the results.</p>"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
subject = "${env.JOB_NAME} - Build ${env.BUILD_NUMBER} - ${currentBuild.result}"
|
||||||
|
body = """<p>${env.JOB_NAME} - Build ${env.BUILD_NUMBER} - ${currentBuild.result}:</p>
|
||||||
|
<p>Check console output at <a href='${env.BUILD_URL}'>${env.BUILD_URL}</a> to view the results.</p>"""
|
||||||
|
}
|
||||||
|
|
||||||
|
emailext(
|
||||||
|
subject: subject,
|
||||||
|
body: body,
|
||||||
|
to: buildEnv.notificationRecipients
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
parallel(executions)
|
parallel(executions)
|
||||||
|
|
Loading…
Reference in New Issue