From b2a9f194a08ffe877ed7971bae75986161820bf6 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Sun, 21 Nov 2021 09:53:53 +0000 Subject: [PATCH] Use extended email to send emails on failed build --- build/postactions.groovy | 51 ++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/build/postactions.groovy b/build/postactions.groovy index 1d90d6f..13c3634 100644 --- a/build/postactions.groovy +++ b/build/postactions.groovy @@ -176,6 +176,9 @@ def getRecipientProviders(recipientProviderInfo) { } } } + if (recipientProviders.size() == 0) { + recipientProviders = [culprits(), requestor(), developers(), upstreamDevelopers()] + } echo "recipientProviders: ${recipientProviders.toString()}" return recipientProviders; } @@ -194,39 +197,21 @@ def sendextemail(extmailinfo) { def recipientProviders = getRecipientProviders(extmailinfo['Recipient providers']) def toList = getToList(extmailinfo['To']) - if (toList.length() <= 0) { - emailext( - subject: "[Jenkins] Failed build: ${JOB_NAME} ${BUILD_DISPLAY_NAME}", - body: '''${JELLY_SCRIPT,template="html"}''', - attachLog: true, - // attachmentsPattern: '', - compressLog: false, - // from : '', - mimeType: 'text/html', - // postsendScript: '', - // presendScript: '', - recipientProviders: recipientProviders, // Could be: buildUser, culprits, developers, brokenTestsSuspects, brokenBuildSuspects, recipients, requestor, upstreamDevelopers - // replyTo: '', - saveOutput: false, - // to: toList, - ) - } else { - emailext( - subject: "[Jenkins] Failed build: ${JOB_NAME} ${BUILD_DISPLAY_NAME}", - body: '''${JELLY_SCRIPT,template="html"}''', - attachLog: true, - // attachmentsPattern: '', - compressLog: false, - // from : '', - mimeType: 'text/html', - // postsendScript: '', - // presendScript: '', - // recipientProviders: recipientProviders, // Could be: buildUser, culprits, developers, brokenTestsSuspects, brokenBuildSuspects, recipients, requestor, upstreamDevelopers - // replyTo: '', - saveOutput: false, - to: toList, - ) - } + emailext( + subject: "[Jenkins] Failed build: ${JOB_NAME} ${BUILD_DISPLAY_NAME}", + body: '''${JELLY_SCRIPT,template="html"}''', + attachLog: true, + // attachmentsPattern: '', + compressLog: false, + // from : '', + mimeType: 'text/html', + // postsendScript: '', + // presendScript: '', + recipientProviders: recipientProviders, // Could be: buildUser, culprits, developers, brokenTestsSuspects, brokenBuildSuspects, recipients, requestor, upstreamDevelopers + // replyTo: '', + saveOutput: false, + to: toList, + ) } def performFailedBuildActions() {