Skip to content

Commit e91d8ae

Browse files
authored
Include synthetic stages in graph and console logs (#86)
1 parent b9407f8 commit e91d8ae

File tree

13 files changed

+111
-19
lines changed

13 files changed

+111
-19
lines changed

src/main/frontend/pipeline-console-view/pipeline-console/main/DataTreeView.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ export interface TreeItemData {
3535
children: TreeItemData[];
3636
}
3737

38+
interface StageTreeItemProps extends TreeItemProps {
39+
synthetic?: boolean;
40+
}
41+
3842
// Tree Item for stages
3943
const StageTreeItem = withStyles((theme: Theme) =>
4044
createStyles({
@@ -49,8 +53,12 @@ const StageTreeItem = withStyles((theme: Theme) =>
4953
paddingLeft: 18,
5054
borderLeft: `1px dashed ${fade(theme.palette.text.primary, 0.4)}`,
5155
},
56+
label: {
57+
fontStyle: (props: StageTreeItemProps) =>
58+
props.synthetic ? "italic" : "inherit",
59+
},
5260
})
53-
)((props: TreeItemProps) => <TreeItem {...props} />);
61+
)((props: StageTreeItemProps) => <TreeItem {...props} />);
5462

5563
// Tree Item for steps
5664
const StepTreeItem = withStyles((theme: Theme) =>
@@ -93,6 +101,7 @@ const getTreeItemsFromStage = (
93101
nodeId={String(stageItemData.id)}
94102
label={stageItemData.name}
95103
children={children}
104+
synthetic={stageItemData.synthetic}
96105
/>
97106
);
98107
});

src/main/frontend/pipeline-graph-view/pipeline-graph/main/PipelineGraphModel.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export interface StageInfo {
5353
children: Array<StageInfo>; // Used by the top-most stages with parallel branches
5454
nextSibling?: StageInfo; // Used within a parallel branch to denote sequential stages
5555
isSequential?: boolean;
56+
synthetic?: boolean;
5657
}
5758

5859
interface BaseNodeInfo {

src/main/frontend/pipeline-graph-view/pipeline-graph/main/support/labels.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ export function BigLabel({
7777
) {
7878
classNames.push("selected");
7979
}
80+
if (details.stage && details.stage.synthetic) {
81+
classNames.push("synthetic");
82+
}
8083

8184
return (
8285
<TruncatingLabel

src/main/frontend/pipeline-graph-view/pipeline-graph/styles/PipelineGraphWidget.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ circle.halo {
142142
font-weight: bold;
143143
}
144144

145+
.PWGx-pipeline-big-label.synthetic {
146+
font-style: italic;
147+
}
148+
145149
.PWGx-pipeline-small-label.selected {
146150
font-weight: bold;
147151
margin-top: 3px;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,4 +277,8 @@ public void setPipelineActions(Collection<Action> pipelineActions) {
277277
public String getArgumentsAsString() {
278278
return PipelineNodeUtil.getArgumentsAsString(node);
279279
}
280+
281+
public boolean isSynthetic() {
282+
return PipelineNodeUtil.isSyntheticStage(node);
283+
}
280284
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ private List<PipelineStageInternal> getPipelineNodes() {
4646
50, // TODO how ???
4747
flowNodeWrapper.getType().name(),
4848
flowNodeWrapper
49-
.getDisplayName() // TODO blue ocean uses timing information: "Passed in 0s"
50-
);
49+
.getDisplayName(), // TODO blue ocean uses timing information: "Passed in 0s"
50+
flowNodeWrapper.isSynthetic());
5151
})
5252
.collect(Collectors.toList());
5353
}

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,6 @@ public void chunkStart(
137137
startNode.getId(), startNode.getDisplayName(), startNode.getDisplayFunctionName()));
138138
}
139139

140-
if (PipelineNodeUtil.isSyntheticStage(startNode)) {
141-
return;
142-
}
143140
if (NotExecutedNodeAction.isExecuted(startNode)) {
144141
firstExecuted = startNode;
145142
}
@@ -174,8 +171,6 @@ public void chunkEnd(
174171
// if block stage node push it to stack as it may have nested stages
175172
if (parallelEnds.isEmpty()
176173
&& endNode instanceof StepEndNode
177-
&& !PipelineNodeUtil.isSyntheticStage(
178-
((StepEndNode) endNode).getStartNode()) // skip synthetic stages
179174
&& PipelineNodeUtil.isStage(((StepEndNode) endNode).getStartNode())) {
180175

181176
// XXX: There seems to be bug in eventing, chunkEnd is sent twice for the same FlowNode
@@ -214,10 +209,6 @@ protected void handleChunkDone(@NonNull MemoryFlowChunk chunk) {
214209
chunk.getFirstNode().getDisplayFunctionName()));
215210
}
216211

217-
if (PipelineNodeUtil.isSyntheticStage(chunk.getFirstNode())) {
218-
return;
219-
}
220-
221212
boolean parallelNestedStages = false;
222213

223214
// it's nested stages inside parallel so let's collect them later

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,20 @@
2727
/** @author Vivek Pandey */
2828
public class PipelineNodeUtil {
2929

30+
private static final String DECLARATIVE_DISPLAY_NAME_PREFIX = "Declarative: ";
31+
3032
public static String getDisplayName(@NonNull FlowNode node) {
3133
ThreadNameAction threadNameAction = node.getAction(ThreadNameAction.class);
32-
return threadNameAction != null ? threadNameAction.getThreadName() : node.getDisplayName();
34+
String name =
35+
threadNameAction != null ? threadNameAction.getThreadName() : node.getDisplayName();
36+
return isSyntheticStage(node) && name.startsWith(DECLARATIVE_DISPLAY_NAME_PREFIX)
37+
? name.substring(DECLARATIVE_DISPLAY_NAME_PREFIX.length())
38+
: name;
3339
}
3440

3541
public static boolean isStage(FlowNode node) {
3642
return node != null
37-
&& ((node.getAction(StageAction.class) != null && !isSyntheticStage(node))
43+
&& ((node.getAction(StageAction.class) != null)
3844
|| (node.getAction(LabelAction.class) != null
3945
&& node.getAction(ThreadNameAction.class) == null));
4046
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class PipelineStage {
1414
private String seqContainerName;
1515
private final PipelineStage nextSibling;
1616
private boolean sequential;
17+
private boolean synthetic;
1718

1819
public PipelineStage(
1920
String id,
@@ -25,7 +26,8 @@ public PipelineStage(
2526
String title,
2627
String seqContainerName,
2728
PipelineStage nextSibling,
28-
boolean sequential) {
29+
boolean sequential,
30+
boolean synthetic) {
2931
this.id = id;
3032
this.name = name;
3133
this.children = children;
@@ -36,6 +38,7 @@ public PipelineStage(
3638
this.seqContainerName = seqContainerName;
3739
this.nextSibling = nextSibling;
3840
this.sequential = sequential;
41+
this.synthetic = synthetic;
3942
}
4043

4144
public PipelineStage getNextSibling() {
@@ -79,4 +82,8 @@ public String getType() {
7982
public String getTitle() {
8083
return title;
8184
}
85+
86+
public boolean isSynthetic() {
87+
return synthetic;
88+
}
8289
}

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class PipelineStageInternal {
1515
private String seqContainerName;
1616
private PipelineStageInternal nextSibling;
1717
private boolean sequential;
18+
private boolean synthetic;
1819

1920
public PipelineStageInternal(
2021
String id,
@@ -23,14 +24,16 @@ public PipelineStageInternal(
2324
String state,
2425
int completePercent,
2526
String type,
26-
String title) {
27+
String title,
28+
boolean synthetic) {
2729
this.id = id;
2830
this.name = name;
2931
this.parents = parents;
3032
this.state = state;
3133
this.completePercent = completePercent;
3234
this.type = type;
3335
this.title = title;
36+
this.synthetic = synthetic;
3437
}
3538

3639
public boolean isSequential() {
@@ -105,6 +108,14 @@ public String getTitle() {
105108
return title;
106109
}
107110

111+
public boolean isSynthetic() {
112+
return synthetic;
113+
}
114+
115+
public void setSynthetic(boolean synthetic) {
116+
this.synthetic = synthetic;
117+
}
118+
108119
public PipelineStage toPipelineStage(List<PipelineStage> children) {
109120
return new PipelineStage(
110121
id,
@@ -116,6 +127,7 @@ public PipelineStage toPipelineStage(List<PipelineStage> children) {
116127
title,
117128
seqContainerName,
118129
nextSibling != null ? nextSibling.toPipelineStage(Collections.emptyList()) : null,
119-
sequential);
130+
sequential,
131+
synthetic);
120132
}
121133
}

0 commit comments

Comments
 (0)