Skip to content
Permalink
Browse files

[JENKINS-41276] Reverting back to check the InterruptedBuilAction

Because the FlowInterruptedAction didn't contain any causes.
Added an extra check in the test to make sure the build is actually
aborted and doesn't continue to run after the retry.
  • Loading branch information
rsandell committed Jan 30, 2017
1 parent 3c2bba9 commit 3c9dfec7b287d6f8b6b17febf9d069e9571b7468
@@ -2,7 +2,6 @@

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.AbortException;
import hudson.model.Result;
import hudson.model.Run;
import hudson.model.TaskListener;
import jenkins.model.CauseOfInterruption;
@@ -67,11 +66,13 @@ public void onFailure(StepContext context, Throwable t) {
try {
Run run = context.get(Run.class);
if (run != null && t instanceof FlowInterruptedException) {
FlowInterruptedException fie = (FlowInterruptedException) t;
for (CauseOfInterruption cause : fie.getCauses()) {
if (cause instanceof CauseOfInterruption.UserInterruption) {
context.onFailure(t);
return;
InterruptedBuildAction action = run.getAction(InterruptedBuildAction.class);
if (action != null) {
for (CauseOfInterruption cause : action.getCauses()) {
if (cause instanceof CauseOfInterruption.UserInterruption) {
context.onFailure(t);
return;
}
}
}
}
@@ -12,8 +12,6 @@
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;

import java.io.IOException;

import static org.junit.Assert.*;

/**
@@ -31,7 +29,7 @@
public void abortShouldNotRetry() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition(
"int count = 0; retry(3) { echo 'trying '+(count++); semaphore 'start'; echo 'NotHere' }", true));
"int count = 0; retry(3) { echo 'trying '+(count++); semaphore 'start'; echo 'NotHere' } echo 'NotHere'", true));
WorkflowRun b = p.scheduleBuild2(0).waitForStart();
SemaphoreStep.waitForStart("start/1", b);
b.doStop();

0 comments on commit 3c9dfec

Please sign in to comment.