[NC-1946] fix slack notifications for master build status (#335)

Chris Mckay 6 years ago committed by GitHub
parent 22498da50c
commit 25bc82f6ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      Jenkinsfile

22
Jenkinsfile vendored

@ -18,6 +18,7 @@ if (env.BRANCH_NAME == "master") {
]) ])
} }
try {
stage('Pantheon tests') { stage('Pantheon tests') {
parallel javaTests: { parallel javaTests: {
node { node {
@ -86,21 +87,32 @@ stage('Pantheon tests') {
} }
} }
} }
} catch (e) {
currentBuild.result = 'FAILURE'
} finally {
// If we're on master and it failed, notify slack // If we're on master and it failed, notify slack
if (env.BRANCH_NAME == "master") { if (env.BRANCH_NAME == "master") {
if (currentBuild.result != 'SUCCESSFUL') { def currentResult = currentBuild.result ?: 'SUCCESS'
def channel = '#priv-pegasys-prod-dev' def channel = '#priv-pegasys-prod-dev'
if (currentBuild.result == 'FAILURE') { if (currentResult == 'SUCCESS') {
def previousResult = currentBuild.previousBuild?.result
if (previousResult != null && (previousResult == 'FAILURE' || previousResult == 'UNSTABLE')) {
slackSend(
color: 'good',
message: "Pantheon branch ${env.BRANCH_NAME} build is back to HEALTHY.\nBuild Number: #${env.BUILD_NUMBER}\n${env.BUILD_URL}",
channel: channel
)
}
} else if (currentBuild.result == 'FAILURE') {
slackSend( slackSend(
color: 'danger', color: 'danger',
msg: "Pantheon master branch build is FAILING.\nBuild Number: #${env.BUILD_NUMBER}\n${env.BUILD_URL}", message: "Pantheon branch ${env.BRANCH_NAME} build is FAILING.\nBuild Number: #${env.BUILD_NUMBER}\n${env.BUILD_URL}",
channel: channel channel: channel
) )
} else if (currentBuild.result == 'UNSTABLE') { } else if (currentBuild.result == 'UNSTABLE') {
slackSend( slackSend(
color: 'warning', color: 'warning',
msg: "Pantheon master branch build is UNSTABLE.\nBuild Number: #${env.BUILD_NUMBER}\n${env.BUILD_URL}", message: "Pantheon branch ${env.BRANCH_NAME} build is UNSTABLE.\nBuild Number: #${env.BUILD_NUMBER}\n${env.BUILD_URL}",
channel: channel channel: channel
) )
} }

Loading…
Cancel
Save