Search in sources :

Example 1 with AtomNode

use of org.jenkinsci.plugins.workflow.graph.AtomNode in project blueocean-plugin by jenkinsci.

the class PipelineStepVisitor method handleChunkDone.

@Override
protected void handleChunkDone(@Nonnull MemoryFlowChunk chunk) {
    if (stageStepsCollectionCompleted) {
        //if its completed no further action
        return;
    }
    if (node != null && chunk.getFirstNode().equals(node)) {
        stageStepsCollectionCompleted = true;
        inStageScope = false;
        try {
            final String cause = PipelineNodeUtil.getCauseOfBlockage(chunk.getFirstNode(), agentNode, run);
            if (cause != null) {
                //Now add a step that indicates bloackage cause
                FlowNode step = new AtomNode(chunk.getFirstNode().getExecution(), UUID.randomUUID().toString(), chunk.getFirstNode()) {

                    @Override
                    protected String getTypeDisplayName() {
                        return cause;
                    }
                };
                FlowNodeWrapper stepNode = new FlowNodeWrapper(step, new NodeRunStatus(BlueRun.BlueRunResult.UNKNOWN, BlueRun.BlueRunState.QUEUED), new TimingInfo(), run);
                steps.push(stepNode);
                stepMap.put(step.getId(), stepNode);
            }
        } catch (IOException | InterruptedException e) {
            //log the error but don't fail. This is better as in worst case all we will lose is blockage cause of a node.
            logger.error(String.format("Error trying to get blockage status of pipeline: %s, runId: %s node block: %s. %s", run.getParent().getFullName(), run.getId(), agentNode, e.getMessage()), e);
        }
    }
    if (node != null && PipelineNodeUtil.isStage(node) && !inStageScope && !chunk.getFirstNode().equals(node)) {
        resetSteps();
    }
}
Also used : TimingInfo(org.jenkinsci.plugins.workflow.pipelinegraphanalysis.TimingInfo) IOException(java.io.IOException) AtomNode(org.jenkinsci.plugins.workflow.graph.AtomNode) StepAtomNode(org.jenkinsci.plugins.workflow.cps.nodes.StepAtomNode) FlowNode(org.jenkinsci.plugins.workflow.graph.FlowNode)

Aggregations

IOException (java.io.IOException)1 StepAtomNode (org.jenkinsci.plugins.workflow.cps.nodes.StepAtomNode)1 AtomNode (org.jenkinsci.plugins.workflow.graph.AtomNode)1 FlowNode (org.jenkinsci.plugins.workflow.graph.FlowNode)1 TimingInfo (org.jenkinsci.plugins.workflow.pipelinegraphanalysis.TimingInfo)1