提交 0578424c 编写于 作者: K kohsuke

create a thread for recurring failures and their eventual "problem solved" message.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@5829 71c3de6d-444a-0410-be80-ed276b4c234a
上级 9081f175
package hudson.tasks;
import hudson.model.Action;
/**
* Remembers the message ID of the e-mail that was sent for the build.
*
* <p>
* This allows us to send further updates as replies.
*
* @author Kohsuke Kawaguchi
*/
public class MailMessageIdAction implements Action {
/**
* Message ID of the e-mail sent for the build.
*/
public final String messageId;
public MailMessageIdAction(String messageId) {
this.messageId = messageId;
}
public String getIconFileName() {
return null;
}
public String getDisplayName() {
return "Message Id"; // but this is never supposed to be displayed
}
public String getUrlName() {
return null; // no web binding
}
}
......@@ -56,6 +56,14 @@ public class MailSender<P extends AbstractProject<P, B>, B extends AbstractBuild
try {
MimeMessage mail = getMail(build, listener);
if (mail != null) {
// if the previous e-mail was sent for a success, this new e-mail
// is not a follow up
B pb = build.getPreviousBuild();
if(pb!=null && pb.getResult()==Result.SUCCESS) {
mail.removeHeader("In-Reply-To");
mail.removeHeader("References");
}
Address[] allRecipients = mail.getAllRecipients();
if (allRecipients != null) {
StringBuffer buf = new StringBuffer("Sending e-mails to:");
......@@ -63,6 +71,8 @@ public class MailSender<P extends AbstractProject<P, B>, B extends AbstractBuild
buf.append(' ').append(a);
listener.getLogger().println(buf);
Transport.send(mail);
build.addAction(new MailMessageIdAction(mail.getMessageID()));
} else {
listener.getLogger().println("An attempt to send an e-mail"
+ " to empty list of recipients, ignored.");
......@@ -253,6 +263,16 @@ public class MailSender<P extends AbstractProject<P, B>, B extends AbstractBuild
}
}
msg.setRecipients(Message.RecipientType.TO, rcp.toArray(new InternetAddress[rcp.size()]));
B pb = build.getPreviousBuild();
if(pb!=null) {
MailMessageIdAction b = pb.getAction(MailMessageIdAction.class);
if(b!=null) {
msg.setHeader("In-Reply-To",b.messageId);
msg.setHeader("References",b.messageId);
}
}
return msg;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册