I added it to the Email-ext Recipes [1] page I created on the wiki. slide
1 - https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+Recipes#Email-extRecipes-FilterRecipientsOnDomain On Mon, Apr 14, 2014 at 9:04 AM, Jon Schewe <[email protected]> wrote: > For those that might want to do this themselves. I wanted to only send to > gooddomain.com and not send anywhere else. Here is the script that > worked. > > recipients = msg.getRecipients(javax.mail.Message.RecipientType.TO) > filtered = recipients.findAll { addr -> addr.toString().contains('@ > gooddomain.com') } > msg.setRecipients(javax.mail.Message.RecipientType.TO, filtered as > javax.mail.Address[]) > > > > On Fri, Apr 4, 2014 at 6:31 PM, Jon Schewe <[email protected]> wrote: > >> Awesome, thanks! >> >> >> On Fri, Apr 4, 2014 at 3:09 PM, Slide <[email protected]> wrote: >> >>> Information from the wiki [1] >>> >>> Pre-send Script >>> >>> The pre-send script is a feature which allows you to write a script that >>> can modify the >>> MimeMessage<http://docs.oracle.com/javaee/1.4/api/javax/mail/internet/MimeMessage.html> >>> object >>> prior to sending. This would allow adding custom headers, modifying the >>> body, etc. Predefined variables include: >>> >>> - msg - the MimeMessage object which can be modified >>> - logger - a PrintStream and will write to the job's log. >>> - build - the build this message belongs to >>> - cancel - a boolean, which when set to true will cancel the sending >>> of the email >>> >>> so something like this: >>> >>> recipients = msg.getRecipients(Message.RecipientType.TO) >>> filtered = recipients.findAll { addr -> !addr.toString().contains('@ >>> baddomain.com') } >>> msg.setRecipients(Message.RecipientType.TO, filtered) >>> >>> slide >>> >>> >>> 1 - https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin >>> >>> >>> On Fri, Apr 4, 2014 at 12:31 PM, Jon Schewe <[email protected]> wrote: >>> >>>> Oh, that doesn't sound too bad. Can you point me at some documentation >>>> and/or examples? >>>> >>>> Thanks. >>>> >>>> >>>> On Tue, Apr 1, 2014 at 5:23 PM, Slide <[email protected]> wrote: >>>> >>>>> No, you use Groovy for the pre-send script. There is no other plugin >>>>> that I know of. >>>>> >>>>> >>>>> On Tue, Apr 1, 2014 at 3:14 PM, Jon Schewe <[email protected]> wrote: >>>>> >>>>>> Which would need some custom Java code, correct? >>>>>> >>>>>> Is there another plugin that might work? >>>>>> >>>>>> >>>>>> On Tue, Apr 1, 2014 at 4:58 PM, Slide <[email protected]> wrote: >>>>>> >>>>>>> No, culprits comes from Jenkins itself. The best you could do is >>>>>>> have a presend script that modifies the MimeMessage's To list. >>>>>>> >>>>>>> >>>>>>> On Tue, Apr 1, 2014 at 2:56 PM, Jon Schewe <[email protected]> wrote: >>>>>>> >>>>>>>> I use the email-ext plugin to send out emails about build failures. >>>>>>>> I originally had it set to send email to all culprits when the build >>>>>>>> failed. However I import some code from other repositories and then >>>>>>>> Jenkins >>>>>>>> wanted to send emails to people that weren't on my development team >>>>>>>> because >>>>>>>> of these imports. Is there a way to tell email-ext to only send email >>>>>>>> to a >>>>>>>> particular domain when picking the culprits? >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> http://mtu.net/~jpschewe >>>>>>>> >>>>>>>> -- >>>>>>>> You received this message because you are subscribed to the Google >>>>>>>> Groups "Jenkins Users" group. >>>>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>>>> send an email to [email protected]. >>>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> Website: http://earl-of-code.com >>>>>>> >>>>>>> -- >>>>>>> You received this message because you are subscribed to the Google >>>>>>> Groups "Jenkins Users" group. >>>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>>> send an email to [email protected]. >>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> http://mtu.net/~jpschewe >>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Jenkins Users" group. >>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>> send an email to [email protected]. >>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Website: http://earl-of-code.com >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Jenkins Users" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to [email protected]. >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> >>>> >>>> >>>> -- >>>> http://mtu.net/~jpschewe >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Jenkins Users" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> >>> >>> -- >>> Website: http://earl-of-code.com >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Jenkins Users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- >> http://mtu.net/~jpschewe >> >> > > > -- > http://mtu.net/~jpschewe > > -- > You received this message because you are subscribed to the Google Groups > "Jenkins Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- Website: http://earl-of-code.com -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
