use of org.jenkinsci.plugins.workflow.cps.nodes.StepAtomNode in project blueocean-plugin by jenkinsci.
the class PipelineNodeGraphVisitor method parallelStart.
@Override
public void parallelStart(@Nonnull FlowNode parallelStartNode, @Nonnull FlowNode branchNode, @Nonnull ForkScanner scanner) {
if (isNodeVisitorDumpEnabled) {
dump(String.format("parallelStart=> id: %s, name: %s, function: %s", parallelStartNode.getId(), parallelStartNode.getDisplayName(), parallelStartNode.getDisplayFunctionName()));
dump(String.format("\tbranch=> id: %s, name: %s, function: %s", branchNode.getId(), branchNode.getDisplayName(), branchNode.getDisplayFunctionName()));
}
if (nestedbranches.size() != parallelBranchEndNodes.size()) {
logger.error(String.format("nestedBranches size: %s not equal to parallelBranchEndNodes: %s", nestedbranches.size(), parallelBranchEndNodes.size()));
return;
}
while (!nestedbranches.empty() && !parallelBranchEndNodes.empty()) {
FlowNode branchStartNode = nestedbranches.pop();
FlowNode endNode = parallelBranchEndNodes.pop();
TimingInfo times;
NodeRunStatus status;
if (endNode != null) {
times = StatusAndTiming.computeChunkTiming(run, chunk.getPauseTimeMillis(), branchStartNode, endNode, chunk.getNodeAfter());
if (endNode instanceof StepAtomNode) {
if (PipelineNodeUtil.isPausedForInputStep((StepAtomNode) endNode, inputAction)) {
status = new NodeRunStatus(BlueRun.BlueRunResult.UNKNOWN, BlueRun.BlueRunState.PAUSED);
} else {
status = new NodeRunStatus(endNode);
}
} else {
GenericStatus genericStatus = StatusAndTiming.computeChunkStatus(run, parallelStartNode, branchStartNode, endNode, parallelEnd);
status = new NodeRunStatus(genericStatus);
}
} else {
times = new TimingInfo(TimingAction.getStartTime(branchStartNode) + System.currentTimeMillis(), chunk.getPauseTimeMillis(), TimingAction.getStartTime(branchStartNode));
status = new NodeRunStatus(BlueRun.BlueRunResult.UNKNOWN, BlueRun.BlueRunState.RUNNING);
}
FlowNodeWrapper branch = new FlowNodeWrapper(branchStartNode, status, times, run);
if (nextStage != null) {
branch.addEdge(nextStage.getId());
}
parallelBranches.push(branch);
}
FlowNodeWrapper[] sortedBranches = parallelBranches.toArray(new FlowNodeWrapper[parallelBranches.size()]);
Arrays.sort(sortedBranches, new Comparator<FlowNodeWrapper>() {
@Override
public int compare(FlowNodeWrapper o1, FlowNodeWrapper o2) {
return o1.getDisplayName().compareTo(o2.getDisplayName());
}
});
parallelBranches.clear();
for (int i = 0; i < sortedBranches.length; i++) {
parallelBranches.push(sortedBranches[i]);
}
for (FlowNodeWrapper p : parallelBranches) {
nodes.push(p);
nodeMap.put(p.getId(), p);
}
//reset parallelEnd node for next parallel block
this.parallelEnd = null;
}
use of org.jenkinsci.plugins.workflow.cps.nodes.StepAtomNode in project blueocean-plugin by jenkinsci.
the class PipelineStepVisitor method atomNode.
@Override
public void atomNode(@CheckForNull FlowNode before, @Nonnull FlowNode atomNode, @CheckForNull FlowNode after, @Nonnull ForkScanner scan) {
if (stageStepsCollectionCompleted && !PipelineNodeUtil.isSyntheticStage(currentStage)) {
return;
}
if (atomNode instanceof StepEndNode) {
this.closestEndNode = (StepEndNode) atomNode;
}
if (atomNode instanceof StepAtomNode && !PipelineNodeUtil.isSkippedStage(currentStage)) {
//if skipped stage, we don't collect its steps
long pause = PauseAction.getPauseDuration(atomNode);
chunk.setPauseTimeMillis(chunk.getPauseTimeMillis() + pause);
TimingInfo times = StatusAndTiming.computeChunkTiming(run, pause, atomNode, atomNode, after);
if (times == null) {
times = new TimingInfo();
}
NodeRunStatus status;
InputStep inputStep = null;
if (PipelineNodeUtil.isPausedForInputStep((StepAtomNode) atomNode, inputAction)) {
status = new NodeRunStatus(BlueRun.BlueRunResult.UNKNOWN, BlueRun.BlueRunState.PAUSED);
try {
for (InputStepExecution execution : inputAction.getExecutions()) {
FlowNode node = execution.getContext().get(FlowNode.class);
if (node != null && node.equals(atomNode)) {
inputStep = execution.getInput();
break;
}
}
} catch (IOException | InterruptedException | TimeoutException e) {
logger.error("Error getting FlowNode from execution context: " + e.getMessage(), e);
}
} else {
status = new NodeRunStatus(atomNode);
}
FlowNodeWrapper node = new FlowNodeWrapper(atomNode, status, times, inputStep, run);
if (PipelineNodeUtil.isPreSyntheticStage(currentStage)) {
preSteps.add(node);
} else if (PipelineNodeUtil.isPostSyntheticStage(currentStage)) {
postSteps.add(node);
} else {
if (!steps.contains(node)) {
steps.push(node);
}
}
stepMap.put(node.getId(), node);
//If there is closest block boundary, we capture it's error to the last step encountered and prepare for next block.
if (closestEndNode != null && closestEndNode.getError() != null) {
node.setBlockErrorAction(closestEndNode.getError());
//prepare for next block
closestEndNode = null;
}
}
}
use of org.jenkinsci.plugins.workflow.cps.nodes.StepAtomNode in project blueocean-plugin by jenkinsci.
the class LinkResolverImpl method resolve.
@Override
public Link resolve(Object modelObject) {
if (modelObject instanceof FlowNode) {
FlowNode flowNode = (FlowNode) modelObject;
BlueRun r = resolveFlowNodeRun(flowNode);
if (PipelineNodeUtil.isParallelBranch(flowNode) || PipelineNodeUtil.isStage(flowNode)) {
// its Node
if (r != null) {
return r.getLink().rel("nodes/" + flowNode.getId());
}
} else if (flowNode instanceof StepAtomNode && !PipelineNodeUtil.isStage(flowNode)) {
if (r != null) {
return r.getLink().rel("steps/" + flowNode.getId());
}
}
} else if (modelObject instanceof BluePipelineNode || modelObject instanceof BluePipelineStep) {
return ((Resource) modelObject).getLink();
}
return null;
}
Aggregations