Skip to content
Permalink
Browse files

[FIXED JENKINS-44379] Don't retry for any FlowInterruptedException

  • Loading branch information
abayer committed Jan 11, 2018
1 parent 2d44c83 commit bc294db775cdd854e3447a061111d375dcc90837
@@ -187,5 +187,11 @@
<version>0.5.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>pipeline-input-step</artifactId>
<version>2.8</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
@@ -57,12 +57,8 @@ public void onSuccess(StepContext context, Object result) {
public void onFailure(StepContext context, Throwable t) {
try {
if (t instanceof FlowInterruptedException) {
for (CauseOfInterruption cause : ((FlowInterruptedException) t).getCauses()) {
if (cause instanceof CauseOfInterruption.UserInterruption) {
context.onFailure(t);
return;
}
}
context.onFailure(t);
return;
}
left--;
if (left>0) {
@@ -1,12 +1,16 @@
package org.jenkinsci.plugins.workflow.steps;

import com.gargoylesoftware.htmlunit.html.HtmlPage;
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.cps.CpsFlowExecution;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
import org.jenkinsci.plugins.workflow.support.steps.input.InputAction;
import org.jenkinsci.plugins.workflow.support.steps.input.InputStepExecution;
import org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep;
import org.junit.ClassRule;
import org.junit.Rule;
@@ -101,4 +105,37 @@ public void abortShouldNotRetry() throws Exception {

}

@Issue("JENKINS-44379")
@Test
public void inputAbortShouldNotRetry() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("int count = 0\n" +
"retry(3) {\n" +
" echo 'trying '+(count++)\n" +
" input id: 'InputX', message: 'OK?', ok: 'Yes'\n" +
"}\n", true));

QueueTaskFuture<WorkflowRun> queueTaskFuture = p.scheduleBuild2(0);
WorkflowRun run = queueTaskFuture.getStartCondition().get();
CpsFlowExecution execution = (CpsFlowExecution) run.getExecutionPromise().get();

while (run.getAction(InputAction.class) == null) {
execution.waitForSuspension();
}

InputAction inputAction = run.getAction(InputAction.class);
InputStepExecution is = inputAction.getExecution("InputX");
HtmlPage page = r.createWebClient().getPage(run, inputAction.getUrlName());

r.submit(page.getFormByName(is.getId()), "abort");
assertEquals(0, inputAction.getExecutions().size());
queueTaskFuture.get();

r.assertBuildStatus(Result.ABORTED, r.waitForCompletion(run));

r.assertLogContains("trying 0", run);
r.assertLogNotContains("trying 1", run);
r.assertLogNotContains("trying 2", run);
}

}

0 comments on commit bc294db

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