Skip to content
Permalink
Browse files

[FIXED JENKINS-41276] Do not continue to retry when the failure is a …

…user interruption.
  • Loading branch information...
jglick committed Feb 6, 2017
1 parent 3571575 commit 422295a5dbac5192e0320d916fb37838e3c24c87
@@ -68,7 +68,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>2.7</version>
<version>2.9-20170206.170109-1</version> <!-- TODO https://github.com/jenkinsci/workflow-step-api-plugin/pull/20 -->
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
@@ -78,7 +78,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>2.3</version>
<version>2.9-20170206.170109-1</version> <!-- TODO https://github.com/jenkinsci/workflow-step-api-plugin/pull/20 -->
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
@@ -108,7 +108,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>2.3</version>
<version>2.10-20170206.170442-2</version> <!-- TODO https://github.com/jenkinsci/workflow-job-plugin/pull/36 -->
<scope>test</scope>
</dependency>
<dependency>
@@ -66,13 +66,10 @@ public void onFailure(StepContext context, Throwable t) {
try {
Run run = context.get(Run.class);
if (run != null && t instanceof FlowInterruptedException) {
InterruptedBuildAction action = run.getAction(InterruptedBuildAction.class);
if (action != null) {
for (CauseOfInterruption cause : action.getCauses()) {
if (cause instanceof CauseOfInterruption.UserInterruption) {
context.onFailure(t);
return;
}
for (CauseOfInterruption cause : ((FlowInterruptedException) t).getCauses()) {
if (cause instanceof CauseOfInterruption.UserInterruption) {
context.onFailure(t);
return;
}
}
}
@@ -1,7 +1,9 @@
package org.jenkinsci.plugins.workflow.steps;

import hudson.model.Result;
import hudson.model.User;
import hudson.model.queue.QueueTaskFuture;
import hudson.security.ACL;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
@@ -76,18 +78,23 @@ public void smokes() throws Exception {
}
}

@Test(timeout = 50000)
@Issue("JENKINS-41276")
@Test
public void abortShouldNotRetry() throws Exception {
r.jenkins.setSecurityRealm(r.createDummySecurityRealm());
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition(
"int count = 0; retry(3) { echo 'trying '+(count++); semaphore 'start'; echo 'NotHere' } echo 'NotHere'", true));
WorkflowRun b = p.scheduleBuild2(0).waitForStart();
final WorkflowRun b = p.scheduleBuild2(0).waitForStart();
SemaphoreStep.waitForStart("start/1", b);
b.doStop();
b = r.assertBuildStatus(Result.ABORTED, r.waitForCompletion(b));
ACL.impersonate(User.get("dev").impersonate(), new Runnable() {
@Override public void run() {
b.getExecutor().doStop();
}
});
r.assertBuildStatus(Result.ABORTED, r.waitForCompletion(b));
r.assertLogContains("trying 0", b);
r.assertLogContains("Aborted by anonymous", b);
r.assertLogContains("Aborted by dev", b);
r.assertLogNotContains("trying 1", b);
r.assertLogNotContains("trying 2", b);
r.assertLogNotContains("NotHere", b);

0 comments on commit 422295a

Please sign in to comment.
You can’t perform that action at this time.