Created
November 17, 2016 23:04
-
-
Save bmannix/67a3d9053bdace4cc9ad8bc92864101a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def notifyBuild(String buildStatus) { | |
// build status of null means successful | |
buildStatus = buildStatus ?: 'SUCCESSFUL' | |
// Default values | |
def subject = "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'" | |
def summary = "${subject} (${env.BUILD_URL})" | |
def details = """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p> | |
<p>Check console output at "<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p>""" | |
def recipients = emailextrecipients([ | |
[$class: 'CulpritsRecipientProvider'], | |
[$class: 'DevelopersRecipientProvider'], | |
[$class: 'RequesterRecipientProvider'] | |
]) | |
stage('Notify') { | |
emailext ( | |
subject: subject, | |
body: details, | |
to: recipients | |
) | |
} | |
} | |
node { | |
stage('Checkout') { | |
checkout scm | |
} | |
try { | |
stage('Test') { | |
sh 'exit 1' | |
} | |
} | |
catch (e) { | |
currentBuild.result = "FAILED" | |
throw e | |
} | |
finally { | |
notifyBuild(currentBuild.result) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment