Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,17 @@ public void onSuccess(CpsThreadGroup g) {
LOGGER.log(Level.WARNING, "Failed to abort " + owner, x);
}
}
// The interruption above is only delivered into the CPS threads; propagating it (running catch and
// finally blocks, and ultimately ending the program) requires the CPS VM to run the program again,
// which CpsThreadGroup.scheduleRun refuses to do while paused. So drop the pause.
if (g.isPaused()) {
try {
owner.getListener().getLogger().println("Resuming to process abort");
} catch (IOException x) {
LOGGER.log(Level.WARNING, null, x);
}
g.unpause();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,24 @@ public void pause() throws Throwable {
});
}

@Test
public void abortWhilePaused() throws Throwable {
sessions.then(r -> {
WorkflowJob p = r.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("try {semaphore 'wait'} finally {echo 'cleaning up'}", true));
WorkflowRun b = p.scheduleBuild2(0).waitForStart();
SemaphoreStep.waitForStart("wait/1", b);
CpsFlowExecution e = (CpsFlowExecution) b.getExecution();
e.pause(true);
await().atMost(30, TimeUnit.SECONDS).until(e::isPaused);
b.getExecutor().interrupt();
await().atMost(60, TimeUnit.SECONDS).until(() -> !b.isBuilding());
r.assertBuildStatus(Result.ABORTED, b);
assertFalse(e.isPaused());
r.assertLogContains("cleaning up", b);
});
}

@Issue("JENKINS-32015")
@Test
public void quietDown() throws Throwable {
Expand Down
Loading