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

In the Jenkins pipeline, I use 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 (for example, admin@myshop.com ) to the list generated by emailextrecipients . I want this recipient (me or the manager or administrator) to always receive email, but the recipient could be the culprit or the requester, and I do not want emailext to send two recipients to this recipient.

Is there a way to combine " admin@myshop.com " with emailextrecipients ?

+8
source share
3 answers

I don't know how I skipped this, but the answer is in the email-ext document. Use "to:" for additional email addresses and use "recipientProviders:" instead of "to: emailextrecipients". Thus, one could:

 emailext ( subject: email_subject, mimetype: 'text/html', to: ' admin@myshop.com ', recipientProviders: [[$class: 'CulpritsRecipientProvider'],[$class: 'RequesterRecipientProvider']], body: email_body ) 
+12
source

A slight departure from Generic Ratzlaugh's answer if you need to use conditional logic for email recipients.

 def myProviders = [ [$class: 'CulpritsRecipientProvider'], [$class: 'DevelopersRecipientProvider'] ]; myProviders.add ( [$class: 'RequesterRecipientProvider'] ); emailext ( subject: email_subject, mimetype: 'text/html', to: ' admin@myshop.com ', recipientProviders: myProviders, body: email_body ) 
+3
source

Fix @Generic answer. fix mimetype in mimeType

0
source

Source: https://habr.com/ru/post/1266856/


All Articles