How can I configure a different sender email address for each build?

1,880 views
Skip to first unread message

Aaron Kushner

unread,
Jun 20, 2012, 4:36:52 PM6/20/12
to jenkins...@googlegroups.com
I'd like the email sender address to be a different group email address for each build type. I use a single Jenkins instance for various builds (hadoop, mysql, various apache projects, etc) and each of these builds has a team responsible for the outcomes and questions.

For example, I'd like the mysql build failure email messages to come from mysql-...@mycompany.com while the hdfs build messages should come from hdfs-...@mycompany.com.

I looked at the presend option on the email-ext plugin, but had no idea whether I could change the sender with that or how to configure it. 

Any suggestions or help would be appreciated.




Slide

unread,
Jun 20, 2012, 4:40:54 PM6/20/12
to jenkins...@googlegroups.com
With email-ext 2.22 you should be able to change the sender in the
pre-send groovy script (this is a per project script). It provides
access to the MimeMessage object in the script, see [1] for more
information.

slide

1 - https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin
--
Website: http://earl-of-code.com

Aaron Kushner

unread,
Jun 20, 2012, 5:00:34 PM6/20/12
to jenkins...@googlegroups.com
Before posting my questions, I looked through all the templates and code for the mail-ext plugin and was still unclear on how to do this. Can you point me to a script/code that I might have missed. 

Aaron Kushner

unread,
Jul 6, 2012, 1:42:17 PM7/6/12
to jenkins...@googlegroups.com
Here's the answer. Put the following in the pre-send script box.

import javax.mail.Message.RecipientType
import javax.mail.Address
import javax.mail.internet.InternetAddress
import javax.mail.internet.MimeMessage

msg.setFrom(new InternetAddress("john...@server.com"))

vijay.m Gowda

unread,
Jan 1, 2018, 5:57:46 AM1/1/18
to Jenkins Users
super class pre send script working fine with jelly script body
Reply all
Reply to author
Forward
0 new messages