Skip to content

Commit

Permalink
Only return names in getStageOrBranchName if it's a stage or branch (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
thatsmydoing authored Mar 18, 2024
1 parent 09a2925 commit fb71c46
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.jenkinsci.plugins.workflow.actions.ThreadNameAction;
import org.jenkinsci.plugins.workflow.actions.WarningAction;
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
import org.jenkinsci.plugins.workflow.graph.BlockStartNode;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.graph.StepNode;
import org.jenkinsci.plugins.workflow.steps.StepDescriptor;
Expand Down Expand Up @@ -53,9 +54,14 @@ class FlowExecutionAnalyzer {
}

private static Optional<String> getStageOrBranchName(final FlowNode node) {
return getParallelName(node)
.map(Optional::of)
.orElse(getStageName(node));
if (node instanceof BlockStartNode) {
// a stage or parallel branch must be a BlockStartNode
return getParallelName(node).or(() -> getStageName(node));
}
else {
// otherwise, this is a regular step, don't return a name
return Optional.empty();
}
}

private static Optional<String> getStageName(final FlowNode node) {
Expand Down

0 comments on commit fb71c46

Please sign in to comment.