Fix slack messaging in pipelines

This commit is contained in:
Michael Youngstrom
2019-04-18 10:44:45 -04:00
parent e00dbe6484
commit 640ff4ed10
3 changed files with 12 additions and 6 deletions

View File

@@ -216,7 +216,8 @@ pipeline {
propagate: false, wait: false
if (currentBuild.currentResult != "SUCCESS"){
slackSend "`${JOB_NAME}` #${BUILD_NUMBER}: ${currentBuild.currentResult} after ${currentBuild.durationString.replace(' and counting', '')}\n${BUILD_URL}"
slackSend botUser: true,
message: "`${JOB_NAME}` #${BUILD_NUMBER}: ${currentBuild.currentResult} after ${currentBuild.durationString.replace(' and counting', '')}\n${BUILD_URL}"
email_body = "See: <${BUILD_URL}>\n\nChanges:\n"
change_sets = currentBuild.changeSets
@@ -230,7 +231,8 @@ pipeline {
emailext body: email_body,
subject: "Build failed in Jenkins: ${JOB_NAME} #${BUILD_NUMBER}", to: 'testeng@edx.org'
} else if (currentBuild.currentResult == "SUCCESS" && currentBuild.previousBuild.currentResult != "SUCCESS") {
slackSend "`${JOB_NAME}` #${BUILD_NUMBER}: Back to normal after ${currentBuild.durationString.replace(' and counting', '')}\n${BUILD_URL}"
slackSend botUser: true,
message: "`${JOB_NAME}` #${BUILD_NUMBER}: Back to normal after ${currentBuild.durationString.replace(' and counting', '')}\n${BUILD_URL}"
emailext body: "See <${BUILD_URL}>",
subject: "Jenkins Build is back to normal: ${JOB_NAME} #${BUILD_NUMBER}", to: 'testeng@edx.org'
}