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
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<properties>
<revision>2.34</revision>
<changelist>-SNAPSHOT</changelist>
<jenkins.version>2.121.1</jenkins.version>
<jenkins.version>2.138.4</jenkins.version>
<java.level>8</java.level>
<no-test-jar>false</no-test-jar>
<useBeta>true</useBeta>
Expand All @@ -82,7 +82,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>2.32</version>
<version>2.36</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
Expand All @@ -93,13 +93,13 @@
<!-- Satisfy upper bound dependencies -->
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>script-security</artifactId>
<version>1.47</version>
<version>1.50</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>2.59</version>
<version>2.63</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -356,6 +370,9 @@ public void onNewHead(FlowNode node) {
wasCalledBeforeExecListener = true;
}
}
if (node instanceof FlowStartNode) {
wasCalledWithFlowStartNode = true;
}
}
}
}