notify when re-trigger has started

refs DE-111

Test Plan:
1. Ensure that failure message reports patchset number / link when fails.
2. Ensure that re-trigger message reports patchset number / link when starts.

Change-Id: Iccfe85ea8d8f4009a798ce17338272fa06be70f2
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/246678
QA-Review: Aaron Ogata <aogata@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Ryan Norton <rnorton@instructure.com>
Product-Review: Aaron Ogata <aogata@instructure.com>
This commit is contained in:
Aaron Ogata 2020-09-01 10:18:16 -07:00
parent 44a440d589
commit 03f633d7e8
1 changed files with 19 additions and 2 deletions

21
Jenkinsfile vendored
View File

@ -112,11 +112,23 @@ def postFn(status) {
def branchSegment = env.GERRIT_BRANCH ? "[$env.GERRIT_BRANCH]" : ''
def authorSlackId = env.GERRIT_EVENT_ACCOUNT_EMAIL ? slackUserIdFromEmail(email: env.GERRIT_EVENT_ACCOUNT_EMAIL, botUser: true, tokenCredentialId: 'slack-user-id-lookup') : ''
def authorSlackMsg = authorSlackId ? "<@$authorSlackId>" : env.GERRIT_EVENT_ACCOUNT_NAME
def authorSegment = authorSlackMsg ? "Patchset by ${authorSlackMsg}. Please acknowledge and investigate. " : ''
def authorSegment = authorSlackMsg ? "Patchset <${env.GERRIT_CHANGE_URL}|#${env.GERRIT_CHANGE_NUMBER}> by ${authorSlackMsg}. Please acknowledge and investigate. " : ''
slackSend(
channel: getSlackChannel(),
color: 'danger',
message: "${branchSegment}${env.JOB_NAME} failed on merge. ${authorSegment}(<${env.BUILD_URL}|${env.BUILD_NUMBER}>)"
message: "${branchSegment}${env.JOB_NAME} failed on merge. ${authorSegment}(Build <${env.BUILD_URL}|#${env.BUILD_NUMBER}>)"
)
}
}
def maybeSlackSendRetrigger() {
def userCause = currentBuild.getBuildCauses('com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritUserCause')
if(userCause && userCause[0].shortDescription.contains('Retriggered')) {
slackSend(
channel: getSlackChannel(),
color: 'warning',
message: "Patchset <${env.GERRIT_CHANGE_URL}|#${env.GERRIT_CHANGE_NUMBER}> was re-triggered by ${env.GERRIT_EVENT_ACCOUNT_EMAIL}. Build <${env.BUILD_URL}|#${env.BUILD_NUMBER}>"
)
}
}
@ -207,6 +219,11 @@ pipeline {
return
}
// Report retriggers to Slack
if(configuration.isChangeMerged()) {
maybeSlackSendRetrigger()
}
// Use a nospot instance for now to avoid really bad UX. Jenkins currently will
// wait for the current steps to complete (even wait to spin up a node), causing
// extremely long wait times for a restart. Investigation in DE-166 / DE-158.