Use extended email to send emails on failed build
This commit is contained in:
parent
f41825d4b4
commit
66ffedf359
1 changed files with 51 additions and 5 deletions
|
|
@ -38,7 +38,16 @@
|
|||
]
|
||||
},
|
||||
"ExtEmail": {
|
||||
"Description": "Send an email using Extended Email plugin"
|
||||
"Description": "Send an email using Extended Email plugin",
|
||||
"To": [
|
||||
"dan.hawkins@globalinkjetsystems.com"
|
||||
],
|
||||
"Recipient providers": [
|
||||
"culprits",
|
||||
"requestor",
|
||||
"developers",
|
||||
"upstreamDevelopers"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -145,7 +154,44 @@ def sendemails(emailtolist) {
|
|||
}
|
||||
}
|
||||
|
||||
def sendextemail() {
|
||||
def getRecipientProviders(recipientProviderInfo) {
|
||||
def recipientProviders = []
|
||||
|
||||
if (recipientProviderInfo) {
|
||||
def recipientProviderInfoList = recipientProviderInfo['Recipient providers']
|
||||
if (recipientProviderInfoList) {
|
||||
for(rp in recipientProviderInfoList) {
|
||||
if (rp == 'culprits') {
|
||||
recipientProviders.append(culprits())
|
||||
}
|
||||
if (rp == 'requestor') {
|
||||
recipientProviders.append(requestor())
|
||||
}
|
||||
if (rp == 'developers') {
|
||||
recipientProviders.append(developers())
|
||||
}
|
||||
if (rp == 'upstreamDevelopers') {
|
||||
recipientProviders.append(upstreamDevelopers())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return recipientProviders;
|
||||
}
|
||||
|
||||
def String getToList(toListInfo) {
|
||||
def String toList
|
||||
|
||||
if (toListInfo) {
|
||||
toList = toListInfo.join(',')
|
||||
}
|
||||
return toList
|
||||
}
|
||||
|
||||
def sendextemail(extmailinfo) {
|
||||
def recipientProviders = getRecipientProviders(extmailinfo['Recipient providers'])
|
||||
def toList = getToList(extmailinfo['To'])
|
||||
|
||||
emailext(
|
||||
subject: "[Jenkins] Failed build: ${JOB_NAME} ${BUILD_DISPLAY_NAME}",
|
||||
body: '''${JELLY_SCRIPT,template="html"}''',
|
||||
|
|
@ -156,10 +202,10 @@ def sendextemail() {
|
|||
mimeType: 'text/html',
|
||||
// postsendScript: '',
|
||||
// presendScript: '',
|
||||
recipientProviders: [culprits(), requestor(), developers(), upstreamDevelopers()], // Could be: buildUser, culprits, developers, brokenTestsSuspects, brokenBuildSuspects, recipients, requestor, upstreamDevelopers
|
||||
recipientProviders: recipientProviders, // Could be: buildUser, culprits, developers, brokenTestsSuspects, brokenBuildSuspects, recipients, requestor, upstreamDevelopers
|
||||
// replyTo: '',
|
||||
saveOutput: false,
|
||||
to: 'dan.hawkins@globalinkjetsystems.com',
|
||||
to: toList,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -180,7 +226,7 @@ def performFailedBuildActions() {
|
|||
sendemails(emailtolist)
|
||||
}
|
||||
if (postbuildactions['ExtEmail']) {
|
||||
sendextemail()
|
||||
sendextemail(postbuildactions['ExtEmail'])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue