diff --git a/pom.xml b/pom.xml index 5c8a4c27..0eae82c0 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ 2.34 -SNAPSHOT - 2.121.1 + 2.138.4 8 false true @@ -82,7 +82,7 @@ org.jenkins-ci.plugins.workflow workflow-api - 2.32 + 2.36 org.jenkins-ci.plugins.workflow @@ -93,13 +93,13 @@ org.jenkins-ci.plugins script-security - 1.47 + 1.50 test org.jenkins-ci.plugins.workflow workflow-cps - 2.59 + 2.63 test diff --git a/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowRun.java b/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowRun.java index 646878bb..edb1afc0 100644 --- a/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowRun.java +++ b/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowRun.java @@ -317,6 +317,7 @@ public WorkflowRun(WorkflowJob job, File dir) throws IOException { if (!exec.isDone()) { exec.set(newExecution); } + FlowExecutionListener.fireCreated(newExecution); newExecution.start(); // We should probably have the promise set before beginning, no? FlowExecutionListener.fireRunning(newExecution); diff --git a/src/test/java/org/jenkinsci/plugins/workflow/job/WorkflowRunRestartTest.java b/src/test/java/org/jenkinsci/plugins/workflow/job/WorkflowRunRestartTest.java index ab8a56f3..8be67bc5 100644 --- a/src/test/java/org/jenkinsci/plugins/workflow/job/WorkflowRunRestartTest.java +++ b/src/test/java/org/jenkinsci/plugins/workflow/job/WorkflowRunRestartTest.java @@ -37,6 +37,7 @@ import org.jenkinsci.plugins.workflow.flow.GraphListener; import org.jenkinsci.plugins.workflow.graph.FlowEndNode; import org.jenkinsci.plugins.workflow.graph.FlowNode; +import org.jenkinsci.plugins.workflow.graph.FlowStartNode; import org.jenkinsci.plugins.workflow.job.properties.DurabilityHintJobProperty; import org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep; import static org.junit.Assert.*; @@ -268,6 +269,8 @@ public void flowExecutionListener() throws Exception { SemaphoreStep.waitForStart("wait/1", b); ExecListener listener = ExtensionList.lookup(FlowExecutionListener.class).get(ExecListener.class); assertNotNull(listener); + assertTrue(listener.graphListener.wasCalledWithFlowStartNode); + assertEquals(1, listener.created); assertEquals(1, listener.started); assertEquals(0, listener.resumed); assertEquals(0, listener.finished); @@ -281,6 +284,7 @@ public void flowExecutionListener() throws Exception { SemaphoreStep.waitForStart("post-resume/1", b); ExecListener listener = ExtensionList.lookup(FlowExecutionListener.class).get(ExecListener.class); assertNotNull(listener); + assertEquals(0, listener.created); assertEquals(0, listener.started); assertEquals(1, listener.resumed); assertEquals(0, listener.finished); @@ -290,6 +294,7 @@ public void flowExecutionListener() throws Exception { r.assertBuildStatus(Result.FAILURE, r.waitForCompletion(b)); r.assertLogContains("Running for listener", b); + assertEquals(0, listener.created); assertEquals(0, listener.started); assertEquals(1, listener.resumed); assertEquals(1, listener.finished); @@ -300,11 +305,19 @@ public void flowExecutionListener() throws Exception { @TestExtension("flowExecutionListener") public static class ExecListener extends FlowExecutionListener { + int created; int started; int finished; int resumed; ExecGraphListener graphListener = new ExecGraphListener(); + @Override + public void onCreated(FlowExecution execution) { + assertTrue(execution.getCurrentHeads().isEmpty()); + addGraphListenerCheckList(execution); + created++; + } + @Override public void onRunning(FlowExecution execution) { addGraphListenerCheckList(execution); @@ -347,6 +360,7 @@ public void onCompleted(FlowExecution execution) { public static class ExecGraphListener implements GraphListener.Synchronous { boolean wasCalledBeforeExecListener; + boolean wasCalledWithFlowStartNode; @Override public void onNewHead(FlowNode node) { @@ -356,6 +370,9 @@ public void onNewHead(FlowNode node) { wasCalledBeforeExecListener = true; } } + if (node instanceof FlowStartNode) { + wasCalledWithFlowStartNode = true; + } } } }