diff --git a/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsThreadGroup.java b/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsThreadGroup.java index 19981832c..c431e9861 100644 --- a/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsThreadGroup.java +++ b/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsThreadGroup.java @@ -44,6 +44,7 @@ import hudson.model.Result; import hudson.util.XStream2; import jenkins.model.Jenkins; +import jenkins.util.SystemProperties; import jenkins.util.Timer; import org.jenkinsci.plugins.workflow.actions.ErrorAction; import org.jenkinsci.plugins.workflow.cps.persistence.PersistIn; @@ -94,6 +95,11 @@ @PersistIn(PersistenceContext.PROGRAM) @SuppressFBWarnings("SE_BAD_FIELD") // bogus warning about closures public final class CpsThreadGroup implements Serializable { + /** + * Whether to keep pipelines running when preparing for shutdown. Defaults to false (pipelines are paused). + */ + private static boolean keepPipelinesRunningWhenQuietingDown = SystemProperties.getBoolean(CpsThreadGroup.class.getName() + ".keepPipelinesRunningWhenQuietingDown"); + /** * {@link CpsThreadGroup} always belong to the same {@link CpsFlowExecution}. * @@ -303,8 +309,8 @@ public Void call() throws Exception { LOGGER.log(Level.WARNING, null, e); } } - if (paused.get() || j == null || (execution != null && j.isQuietingDown())) { - if (j != null && j.isQuietingDown() && execution != null && pausedByQuietMode.compareAndSet(false, true)) { + if (paused.get() || j == null || (execution != null && j.isQuietingDown() && !keepPipelinesRunningWhenQuietingDown)) { + if (j != null && j.isQuietingDown() && execution != null && !keepPipelinesRunningWhenQuietingDown && pausedByQuietMode.compareAndSet(false, true)) { try { execution.getOwner().getListener().getLogger().println("Pausing (Preparing for shutdown)"); } catch (IOException e) {