Skip to content
Permalink
Browse files
Fixed JENKINS-17577
  • Loading branch information
slide committed Apr 15, 2013
1 parent 88136e7 commit dba4fe1fd045f44037272989cb2926abb033292b
@@ -49,6 +49,7 @@
import java.net.SocketException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@@ -294,13 +295,13 @@ private boolean _perform(AbstractBuild<?, ?> build, BuildListener listener, bool

for (String triggerName : triggered.keySet()) {
listener.getLogger().println("Sending email for trigger: " + triggerName);
sendMail(triggered.get(triggerName).getEmail(), build, listener);
sendMail(triggered.get(triggerName).getEmail(), build, listener, triggered.get(triggerName), triggered);
}

return true;
}

private boolean sendMail(EmailType mailType, AbstractBuild<?, ?> build, BuildListener listener) {
private boolean sendMail(EmailType mailType, AbstractBuild<?, ?> build, BuildListener listener, EmailTrigger trigger, Map<String, EmailTrigger> triggered) {
try {
MimeMessage msg = createMail(mailType, build, listener);
debug(listener.getLogger(), "Successfully created MimeMessage");
@@ -312,7 +313,7 @@ private boolean sendMail(EmailType mailType, AbstractBuild<?, ?> build, BuildLis
buf.append(' ').append(a);
}
listener.getLogger().println(buf);
if(executePresendScript(build, listener, msg)) {
if(executePresendScript(build, listener, msg, trigger, triggered)) {
while(true) {
try {
Transport.send(msg);
@@ -380,7 +381,7 @@ private boolean sendMail(EmailType mailType, AbstractBuild<?, ?> build, BuildLis
return false;
}

private boolean executePresendScript(AbstractBuild<?, ?> build, BuildListener listener, MimeMessage msg)
private boolean executePresendScript(AbstractBuild<?, ?> build, BuildListener listener, MimeMessage msg, EmailTrigger trigger, Map<String, EmailTrigger> triggered)
throws RuntimeException {
boolean cancel = false;
if(StringUtils.isNotBlank(presendScript)) {
@@ -405,6 +406,8 @@ private boolean executePresendScript(AbstractBuild<?, ?> build, BuildListener li
binding.setVariable("msg", msg);
binding.setVariable("logger", listener.getLogger());
binding.setVariable("cancel", cancel);
binding.setVariable("trigger", trigger);
binding.setVariable("triggered", Collections.unmodifiableMap(triggered));

GroovyShell shell = new GroovyShell(cl, binding, cc);
StringWriter out = new StringWriter();
@@ -110,7 +110,6 @@ public void testChangeLogDisplayShouldntOnlyRelyOnPortableMethods2() throws Exce
mockChangeSet(build);

String output = content.evaluate(build, listener, JellyScriptContent.MACRO_NAME);
System.out.println(output);

assertTrue(output.contains("COMMIT MESSAGE"));
assertTrue(output.contains("Kohsuke Kawaguchi"));
@@ -144,8 +144,6 @@ public void testGroovyTemplateWithContentToken()
expected = expected.replace("\r", "");
}

System.out.println(content);

// remove end space before compare
assertEquals(expected.trim(), content.trim());
}

0 comments on commit dba4fe1

Please sign in to comment.