use of org.jenkinsci.plugins.workflow.actions.TimingAction in project blueocean-plugin by jenkinsci.
the class PipelineNodeGraphVisitor method createParallelSyntheticNode.
/**
* Create synthetic stage that wraps a parallel block at top level, that is not enclosed inside a stage.
*/
@Nullable
private FlowNodeWrapper createParallelSyntheticNode() {
if (parallelBranches.isEmpty()) {
return null;
}
FlowNodeWrapper firstBranch = parallelBranches.getLast();
FlowNodeWrapper parallel = firstBranch.getFirstParent();
String firstNodeId = firstBranch.getId();
List<FlowNode> parents;
if (parallel != null) {
parents = parallel.getNode().getParents();
} else {
parents = new ArrayList<>();
}
FlowNode syntheticNode = new FlowNode(firstBranch.getNode().getExecution(), createSyntheticStageId(firstNodeId, PARALLEL_SYNTHETIC_STAGE_NAME), parents) {
@Override
protected String getTypeDisplayName() {
return PARALLEL_SYNTHETIC_STAGE_NAME;
}
};
syntheticNode.addAction(new LabelAction(PARALLEL_SYNTHETIC_STAGE_NAME));
long duration = 0;
long pauseDuration = 0;
long startTime = 0;
//= parallelStartNode.getAction(TimingAction.class);
TimingAction timingAction = null;
if (timingAction != null) {
startTime = timingAction.getStartTime();
}
boolean isCompleted = true;
boolean isPaused = false;
boolean isFailure = false;
boolean isUnknown = false;
for (FlowNodeWrapper pb : parallelBranches) {
if (!isPaused && pb.getStatus().getState() == BlueRun.BlueRunState.PAUSED) {
isPaused = true;
}
if (isCompleted && pb.getStatus().getState() != BlueRun.BlueRunState.FINISHED) {
isCompleted = false;
}
if (!isFailure && pb.getStatus().getResult() == BlueRun.BlueRunResult.FAILURE) {
isFailure = true;
}
if (!isUnknown && pb.getStatus().getResult() == BlueRun.BlueRunResult.UNKNOWN) {
isUnknown = true;
}
duration += pb.getTiming().getTotalDurationMillis();
pauseDuration += pb.getTiming().getPauseDurationMillis();
}
BlueRun.BlueRunState state = isCompleted ? BlueRun.BlueRunState.FINISHED : (isPaused ? BlueRun.BlueRunState.PAUSED : BlueRun.BlueRunState.RUNNING);
BlueRun.BlueRunResult result = isFailure ? BlueRun.BlueRunResult.FAILURE : (isUnknown ? BlueRun.BlueRunResult.UNKNOWN : BlueRun.BlueRunResult.SUCCESS);
TimingInfo timingInfo = new TimingInfo(duration, pauseDuration, startTime);
FlowNodeWrapper synStage = new FlowNodeWrapper(syntheticNode, new NodeRunStatus(result, state), timingInfo, run);
Iterator<FlowNodeWrapper> sortedBranches = parallelBranches.descendingIterator();
while (sortedBranches.hasNext()) {
FlowNodeWrapper p = sortedBranches.next();
p.addParent(synStage);
synStage.addEdge(p.getId());
}
return synStage;
}
Aggregations