Skip to content
Merged
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
6 changes: 6 additions & 0 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@
<scope>import</scope>
<type>pom</type>
</dependency>
<!-- TODO until in BOM -->
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>1259.vb_47f14fffc8a_</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,8 @@ public void pause(final boolean v) throws IOException {
}

@Restricted(DoNotUse.class)
@Terminator public static void suspendAll() {
@Terminator(attains = FlowExecutionList.EXECUTIONS_SUSPENDED)
public static void suspendAll() {
CpsFlowExecution exec = null;
try (Timeout t = Timeout.limit(3, TimeUnit.MINUTES)) { // TODO some complicated sequence of calls to Futures could allow all of them to run in parallel
LOGGER.fine("starting to suspend all executions");
Expand Down Expand Up @@ -2164,10 +2165,4 @@ private void checkAndAbortNonresumableBuild() {
}
}

/** Ensures that even if we're limiting persistence of data for performance, we still write out data for shutdown. */
@Override
protected void notifyShutdown() {
// No-op, handled in the suspendAll terminator
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import jenkins.model.Jenkins;
import org.apache.commons.io.FileUtils;
import org.hamcrest.Matchers;
import static org.hamcrest.Matchers.containsInRelativeOrder;
import org.htmlunit.ElementNotFoundException;
import org.htmlunit.FailingHttpStatusCodeException;
import org.htmlunit.HttpMethod;
Expand All @@ -66,6 +67,7 @@
import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.Whitelisted;
import org.jenkinsci.plugins.workflow.cps.GroovySourceFileAllowlist.DefaultAllowlist;
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.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
Expand Down Expand Up @@ -622,4 +624,16 @@ public boolean isAllowed(String groovyResourceUrl) {
assertThat(EnvActionImpl.forRun(b).getEnvironment().get("foo"), equalTo("bar"));
});
}

@Test public void suspendOrder() throws Throwable {
System.setProperty(Jenkins.class.getName() + "." + "termLogLevel", "INFO");
logger.record(CpsFlowExecution.class, Level.FINE).record(FlowExecutionList.class, Level.FINE).capture(100);
sessions.then(r -> {
WorkflowJob p = r.createProject(WorkflowJob.class);
p.setDefinition(new CpsFlowDefinition("echo 'ok'", true));
r.buildAndAssertSuccess(p);
});
assertThat(logger.getMessages(), containsInRelativeOrder("finished suspending all executions", "ensuring all executions are saved"));
}

}