Merge pull request #1207 from eclipse/np_issue1515

[eclipse/xtext#1515] fine-tune when slack gets notified
This commit is contained in:
Nico Prediger 2019-07-16 17:18:52 +02:00 committed by GitHub
commit 8af91f4319
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -114,7 +114,7 @@ spec:
}
}
}
changed {
cleanup {
script {
def envName = ''
if (env.JENKINS_URL.contains('ci.eclipse.org/xtext')) {
@ -123,19 +123,29 @@ spec:
envName = ' (JIRO)'
}
def curResult = currentBuild.currentResult
def sendNotification = true
def color = '#00FF00'
if (curResult == 'SUCCESS') {
if (currentBuild.previousBuild != null && currentBuild.previousBuild.result != 'SUCCESS') {
curResult = 'FIXED'
}
def curResult = currentBuild.currentResult
def lastResult = 'NONE'
if (currentBuild.previousBuild != null) {
lastResult = currentBuild.previousBuild.result
}
if (lastResult == 'NONE') {
curResult = "NEW: ${curResult}"
} else if (curResult == 'SUCCESS' && lastResult == 'SUCCESS') {
sendNotification = false
} else if (curResult == 'SUCCESS' && lastResult != 'SUCCESS') {
curResult = 'FIXED'
} else if (curResult == 'UNSTABLE') {
curResult = 'STILL FAILING (UNSTABLE)'
color = '#FFFF00'
} else { // FAILURE, ABORTED, NOT_BUILD
curResult = 'STILL FAILING'
color = '#FF0000'
}
slackSend message: "${curResult}: <${env.BUILD_URL}|${env.JOB_NAME}#${env.BUILD_NUMBER}${envName}>", botUser: true, channel: 'xtext-builds', color: "${color}"
if (sendNotification) {
slackSend message: "${curResult}: <${env.BUILD_URL}|${env.JOB_NAME}#${env.BUILD_NUMBER}${envName}>", botUser: true, channel: 'xtext-builds', color: "${color}"
}
}
}
}