Skip to content

Commit

Permalink
[JENKINS-41276] Reverting back to check the InterruptedBuilAction
Browse files Browse the repository at this point in the history
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 3c9dfec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
}
}
Expand Down
Expand Up @@ -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.*;

/**
Expand All @@ -31,7 +29,7 @@ public class RetryStepTest {
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();
Expand Down

0 comments on commit 3c9dfec

Please sign in to comment.