From 469ca857c92dffe0e4316f8ca6b085b70eab634b Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Fri, 23 Aug 2024 20:10:56 -0400 Subject: [PATCH] Save `build.xml` during `CpsFlowExecution.suspendAll` --- .../plugins/workflow/cps/CpsFlowExecution.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsFlowExecution.java b/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsFlowExecution.java index 4a8bc7e72..be725f8c4 100644 --- a/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsFlowExecution.java +++ b/plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsFlowExecution.java @@ -1697,7 +1697,17 @@ public static void suspendAll() { CpsFlowExecution cpsExec = (CpsFlowExecution) execution; try { cpsExec.checkAndAbortNonresumableBuild(); - + if (cpsExec.owner != null) { + try { + Queue.Executable exec = cpsExec.owner.getExecutable(); + if (exec instanceof Saveable) { + LOGGER.fine(() -> "saving " + exec); + ((Saveable) exec).save(); + } + } catch (IOException x) { + LOGGER.log(Level.WARNING, "failed to save " + cpsExec, x); + } + } LOGGER.log(Level.FINE, "waiting to suspend {0}", execution); // Like waitForSuspension but with a timeout: if (cpsExec.programPromise != null) {