Use extended email to send emails on failed build

This commit is contained in:
Dan Hawkins 2021-11-21 17:16:36 +00:00
commit 724179c07a

View file

@ -138,19 +138,23 @@ def performSuccessfulBuildActions() {
deployjob(buildselector, postbuildactions, 'Release to git', 'RELEASE_TO_GIT_JOB')
}
def sendemails(emailtolist) {
def emailbody = """
Failed build: ${JOB_NAME} ${BUILD_DISPLAY_NAME} : ${BUILD_URL}
def sendemails(emailinfo) {
def emailtolist = emailinfo['To']
Console output: ${BUILD_URL}console
"""
for(emailto in emailtolist) {
mail(
subject: "[Jenkins] Failed build: ${JOB_NAME} ${BUILD_DISPLAY_NAME}",
body: emailbody,
to: emailto
)
echo "Send email to: ${emailto}"
if (emailtolist) {
def emailbody = """
Failed build: ${JOB_NAME} ${BUILD_DISPLAY_NAME} : ${BUILD_URL}
Console output: ${BUILD_URL}console
"""
for(emailto in emailtolist) {
mail(
subject: "[Jenkins] Failed build: ${JOB_NAME} ${BUILD_DISPLAY_NAME}",
body: emailbody,
to: emailto
)
echo "Send email to: ${emailto}"
}
}
}
@ -220,9 +224,8 @@ def performFailedBuildActions() {
}
}
if (postbuildactions) {
def emailtolist = postbuildactions['Email']['To']
if (emailtolist) {
sendemails(emailtolist)
if (postbuildactions['Email']) {
sendemails(postbuildactions['Email'])
}
if (postbuildactions['ExtEmail']) {
sendextemail(postbuildactions['ExtEmail'])