Skip to content

Commit

Permalink
Fix JENKINS-27448
Browse files Browse the repository at this point in the history
Remove check for output != null.
  • Loading branch information
Alex Earl committed Apr 8, 2015
1 parent 8b78212 commit 27fbded
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
Expand Up @@ -478,12 +478,9 @@ private boolean executePresendScript(ExtendedEmailPublisherContext context, Mime
}

try {
Object output = shell.evaluate(script);
if (output != null) {
pw.println("Result: " + output);
cancel = ((Boolean) shell.getVariable("cancel"));
debug(context.getListener().getLogger(), "Pre-send script set cancel to %b", cancel);
}
shell.evaluate(script);
cancel = ((Boolean) shell.getVariable("cancel"));
debug(context.getListener().getLogger(), "Pre-send script set cancel to %b", cancel);
} catch (SecurityException e) {
context.getListener().getLogger().println("Pre-send script tried to access secured objects: " + e.getMessage());
} catch (Throwable t) {
Expand Down
Expand Up @@ -60,7 +60,6 @@
import org.jvnet.hudson.test.JenkinsRule.WebClient;
import org.jvnet.hudson.test.MockBuilder;
import org.jvnet.hudson.test.SleepBuilder;
import org.jvnet.hudson.test.recipes.WithPlugin;
import org.jvnet.mock_javamail.Mailbox;
import org.kohsuke.stapler.Stapler;

Expand Down Expand Up @@ -535,6 +534,32 @@ public void testCancelFromPresendScriptCausesNoEmail() throws Exception {

assertEquals(0, Mailbox.get("kutzi@xxx.com").size());
}

@Test
@Issue("JENKINS-27448")
public void testCancelFromPresendScriptCausesNoEmailWithCodeAfter() throws Exception {
publisher.presendScript = "cancel = true\nlogger.println('You are here')";
SuccessTrigger successTrigger = new SuccessTrigger(recProviders, "$DEFAULT_RECIPIENTS",
"$DEFAULT_REPLYTO", "$DEFAULT_SUBJECT", "$DEFAULT_CONTENT", "", 0, "project");
successTrigger.setEmail(new EmailType() {
{
addRecipientProvider(new RequesterRecipientProvider());
}
});
publisher.getConfiguredTriggers().add(successTrigger);

User u = User.get("kutzi");
u.setFullName("Christoph Kutzinski");
Mailer.UserProperty prop = new Mailer.UserProperty("kutzi@xxx.com");
u.addProperty(prop);

UserCause cause = new MockUserCause("kutzi");

FreeStyleBuild build = project.scheduleBuild2(0, cause).get();
j.assertBuildStatusSuccess(build);

assertEquals(0, Mailbox.get("kutzi@xxx.com").size());
}

@Test
@Issue("JENKINS-22777")
Expand Down

0 comments on commit 27fbded

Please sign in to comment.