File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
main/java/org/jenkinsci/plugins/workflow/cps
test/java/org/jenkinsci/plugins/workflow/cps Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1276,6 +1276,8 @@ public List<Action> loadActions(FlowNode node) throws IOException {
12761276 public void saveActions (FlowNode node , List <Action > actions ) throws IOException {
12771277 if (storage == null ) {
12781278 throw new IOException ("storage not yet loaded" );
1279+ } else if (isComplete ()) {
1280+ throw new IOException ("Cannot save actions for " + node + " for completed execution " + this + ": " + actions );
12791281 }
12801282 storage .saveActions (node , actions );
12811283 }
Original file line number Diff line number Diff line change 3333import static org .junit .Assert .assertEquals ;
3434import static org .junit .Assert .assertFalse ;
3535import static org .junit .Assert .assertNotNull ;
36+ import static org .junit .Assert .assertThrows ;
3637import static org .junit .Assert .assertTrue ;
3738import static org .junit .Assert .fail ;
3839
4950import hudson .model .Result ;
5051import hudson .model .TaskListener ;
5152import java .io .File ;
53+ import java .io .IOException ;
5254import java .io .Serializable ;
5355import java .net .HttpURLConnection ;
5456import java .net .MalformedURLException ;
@@ -914,4 +916,15 @@ public boolean takesImplicitBlockArgument() {
914916 });
915917 }
916918
919+ @ Test public void flowNodesCantBeSavedAfterExecutionCompletes () throws Throwable {
920+ sessions .then (r -> {
921+ WorkflowJob p = r .createProject (WorkflowJob .class , "p" );
922+ p .setDefinition (new CpsFlowDefinition ("echo 'Hello, world!'" , true ));
923+ WorkflowRun b = r .buildAndAssertSuccess (p );
924+ FlowNode echoStep = b .getExecution ().getNode ("3" );
925+ IOException e = assertThrows (IOException .class , echoStep ::save );
926+ assertThat (e .getMessage (), containsString ("Cannot save actions for " + echoStep + " for completed execution " + b .getExecution ()));
927+ });
928+ }
929+
917930}
You can’t perform that action at this time.
0 commit comments