Skip to content

Commit

Permalink
[JENKINS-67531] Do not load Pipelines during PlaceholderTask.getCause…
Browse files Browse the repository at this point in the history
…OfBlockage in normal scenarios (#188)

* [JENKINS-67531] Do not load Pipelines during PlaceholderTask.getCauseOfBlockage in normal scenarios

* [JENKINS-67351] Update to workflow-api 1112.v8bce30c92835

* [JENKINS-67351] Update to released version of workflow-api

* [JENKINS-67351] Always return a CauseOfBlockage if the step is stopping
  • Loading branch information
dwnusbaum authored Dec 17, 2021
1 parent 15a6aec commit 5dab75a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>1108.v57edf648f5d4</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import org.jenkinsci.plugins.workflow.actions.QueueItemAction;
import org.jenkinsci.plugins.workflow.actions.ThreadNameAction;
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
import org.jenkinsci.plugins.workflow.flow.FlowExecutionList;
import org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.steps.AbstractStepExecutionImpl;
Expand Down Expand Up @@ -422,11 +423,14 @@ public String getCookie() {
}

@Override public CauseOfBlockage getCauseOfBlockage() {
Run<?, ?> run = runForDisplay();
if (!stopping && run != null && !run.isLogUpdated()) {
stopping = true;
LOGGER.warning(() -> "Refusing to build " + this + " and cancelling it because associated build is complete");
Timer.get().execute(() -> Queue.getInstance().cancel(this));
if (FlowExecutionList.get().isResumptionComplete()) {
// We only do this if resumption is complete so that we do not load the run and resume its execution in this context in normal scenarios.
Run<?, ?> run = runForDisplay();
if (!stopping && run != null && !run.isLogUpdated()) {
stopping = true;
LOGGER.warning(() -> "Refusing to build " + this + " and cancelling it because associated build is complete");
Timer.get().execute(() -> Queue.getInstance().cancel(this));
}
}
if (stopping) {
return new CauseOfBlockage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1299,6 +1299,7 @@ public void accessPermittedOnlyFromCurrentBuild() throws Throwable {
WorkflowRun b = p.getBuildByNumber(1);
assertFalse(b.isLogUpdated());
r.assertBuildStatusSuccess(b);
Queue.getInstance().maintain(); // Otherwise we may have to wait up to 5 seconds.
while (Queue.getInstance().getItems().length > 0) {
Thread.sleep(100L);
}
Expand Down

0 comments on commit 5dab75a

Please sign in to comment.