In Jenkins pipeline I'm using emailext with emailextrecipients
as follows:
emailext (
subject: email_subject,
mimetype: 'text/html',
to: emailextrecipients([[$class: 'CulpritsRecipientProvider'],[$class: 'RequesterRecipientProvider']]),
body: email_body
)
And I want to add a specific email address (e.g. [email protected]) to the list generated using emailextrecipients
. I want that addressee (me or a manager or admin) to always get the email, but the addressee might be a culprit or requester and I don't want emailext to send two emails to that addressee.
Is there a way to merge '[email protected]' with emailextrecipients
?
Enter the recipient email id in the 'E-mail Notification' box and select the checkbox next to the 'Send e-mail for every unstable build' option. Click the 'Advance Settings…' button in the 'Editable Email Notification' box. Click the 'Add Trigger' drop-down and select the 'Always' option and Click the 'Save' button.
It provides customization of three areas: Triggers. Select the conditions that should cause an email notification to be sent. Content.
[[$class: 'DevelopersRecipientProvider']] is a list of map, 'recipientProviders' is the key same as 'subject' or 'body' . You may think the emailext is a method with signature: void emailext(Map<String, Object> map) 3) emailext is a method implemented in Java. You can find source code here and here.
A slight variation to Generic Ratzlaugh's answer, in case you need to use conditional logic for email destinations.
def myProviders = [ [$class: 'CulpritsRecipientProvider'], [$class: 'DevelopersRecipientProvider'] ];
myProviders.add ( [$class: 'RequesterRecipientProvider'] );
emailext (
subject: email_subject,
mimetype: 'text/html',
to: '[email protected]',
recipientProviders: myProviders,
body: email_body
)
I don't know how I missed this, but the answer is in the email-ext doc. Use the to:
for the additional email addresses, and use recipientProviders:
instead of to: emailextrecipients
. So one would have:
emailext (
subject: email_subject,
mimetype: 'text/html',
to: '[email protected]',
recipientProviders: [[$class: 'CulpritsRecipientProvider'],[$class: 'RequesterRecipientProvider']],
body: email_body
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With