Jenkins pipeline emailext emailextrecipients: Can I also add specific, individual email address?

Generic Ratzlaugh picture Generic Ratzlaugh · Apr 18, 2017 · Viewed 12.6k times · Source

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?

Answer

Generic Ratzlaugh picture Generic Ratzlaugh · Apr 18, 2017

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
    )