From 03f633d7e8640d131d880e30dc36db1bdc73c7ce Mon Sep 17 00:00:00 2001 From: Aaron Ogata Date: Tue, 1 Sep 2020 10:18:16 -0700 Subject: [PATCH] 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 Tested-by: Service Cloud Jenkins Reviewed-by: Ryan Norton Product-Review: Aaron Ogata --- Jenkinsfile | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7a27fea6680..569bc8c4640 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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.