Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only return names in getStageOrBranchName if it's a stage or branch #253

Merged
merged 1 commit into from
Mar 18, 2024
Merged
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
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));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the same as the original code, I've just rewritten it to be more idiomatic.

}
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