Override sysadmin address in emails from Jenkins jobs

Posted on March 28th, 2015 at 10:00 AM

Are you tired of your Jenkins job sending email notifications from your sysadmin, and isn't he/she tired of getting replies? Here's a simple fix adding Groovy code to the Editable Email Notification plugin. Simply set the 'fromAddress' string to your email in the following code and add to the Pre-Send Script area in your Editable Email Notification - Advanced Settings:

import javax.mail.internet.*;
import javax.mail.*
import javax.activation.*

fromAddress = "erf.tam@erftam.com"
InternetAddress fromAddr = new InternetAddress(fromAddress)
msg.setFrom(new InternetAddress(fromAddress))