emailext and Declarative Pipeline; multiple "to"

787 views
Skip to first unread message

Zach LaCelle

unread,
Feb 15, 2019, 2:53:41 PM2/15/19
to jenkins...@googlegroups.com
For my "build failed" emails, I'd like to send an email from my Jenkins Declarative Pipeline to the developers group but also to a fixed list of recipients. Under the Pipeline documentation (https://jenkins.io/doc/pipeline/steps/email-ext/), I see a class for "recipients", which states that it includes "recipients defined in the "Project Recipient List.""

My question is: how do I add a list of emails to the "Project Recipient List"? Where is this list defined for Declarative pipelines? If I can add to this list, then I think I can add something like: recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'RecipientsRecipientProvider']]

Or, if I can't do this, then I could also add a "to:" at the end of the emailext declaration. How do I add multiple users to this entry? Are they comma-separated, or semi-colon separated? Will they automatically have the default domain added?

ZillaYT

unread,
Feb 15, 2019, 4:59:27 PM2/15/19
to Jenkins Users
Here's a sample function we call in our pipeline

def processTestFailure() {
    junit
"**/build/test-results/**/*.xml"
    emailext body
: "<strong><font color=\"red\">You broke the build</font></strong><br /><br /> It appears that ${env.BUILD_URL} tests are failing (${currentBuild.result}). <br /><br />Change sets:<br />${changelist()}<br /><br />${testStatuses()}", recipientProviders: [[$class: "FailingTestSuspectsRecipientProvider"], [$class: "FirstFailingBuildSuspectsRecipientProvider"], [$class: "CulpritsRecipientProvider"]], subject: "FAILING TEST - ${env.JOB_NAME} (${env.BUILD_NUMBER}) - ${currentBuild.result}"
}

ZillaYT

unread,
Feb 15, 2019, 5:05:56 PM2/15/19
to Jenkins Users
Here's another function, with multiple "to"

def sendApprovalTransitionEmail(deploymentEnv) {
    emailext body
: "<strong><font color=\"#3090C7\">This build is now paused and awaiting transition by QA.</font></strong><br /><br /> Click here ${env.BUILD_URL} to approve this builds deployment to $deploymentEnv.",
    subject
: "Build is paused - awaiting QA approval ($deploymentEnv)",
    to
: "$watchers,jenki...@company.com"
}


On Friday, February 15, 2019 at 2:53:41 PM UTC-5, Zach LaCelle wrote:
Reply all
Reply to author
Forward
0 new messages