Skip to content

Commit b6dc82f

Browse files
stuartroweStuart Rowe
andauthored
Set the step display name to only the label if set (#164)
Co-authored-by: Stuart Rowe <stuartr@ea.com>
1 parent ccc17ff commit b6dc82f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/main/java/io/jenkins/plugins/pipelinegraphview/utils/FlowNodeWrapper.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.Collections;
1313
import java.util.List;
1414
import org.jenkinsci.plugins.workflow.actions.ErrorAction;
15+
import org.jenkinsci.plugins.workflow.actions.LabelAction;
1516
import org.jenkinsci.plugins.workflow.graph.AtomNode;
1617
import org.jenkinsci.plugins.workflow.graph.FlowNode;
1718
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
@@ -106,6 +107,14 @@ public WorkflowRun getRun() {
106107
return displayName;
107108
}
108109

110+
public @CheckForNull String getLabelDisplayName() {
111+
LabelAction labelAction = node.getAction(LabelAction.class);
112+
if (labelAction != null) {
113+
return labelAction.getDisplayName();
114+
}
115+
return null;
116+
}
117+
109118
private static NodeType getNodeType(FlowNode node) {
110119
if (PipelineNodeUtil.isStage(node)) {
111120
return NodeType.STAGE;

src/main/java/io/jenkins/plugins/pipelinegraphview/utils/PipelineStepApi.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ private List<PipelineStep> parseSteps(List<FlowNodeWrapper> stepNodes, String st
3838
if (stepArguments != null && !stepArguments.isEmpty()) {
3939
displayName = stepArguments + " - " + displayName;
4040
}
41+
42+
// Use the step label as the displayName if set
43+
String labelDisplayName = flowNodeWrapper.getLabelDisplayName();
44+
if (labelDisplayName != null && !labelDisplayName.isEmpty()) {
45+
displayName = labelDisplayName;
46+
}
4147
// Remove non-printable chars (e.g. ANSI color codes).
4248
logger.debug("DisplayName Before: '" + displayName + "'.");
4349
displayName = cleanTextContent(displayName);

0 commit comments

Comments
 (0)