Search in sources :

Example 1 with StepEndNode

use of org.jenkinsci.plugins.workflow.cps.nodes.StepEndNode 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;
        }
    }
}
Also used : TimingInfo(org.jenkinsci.plugins.workflow.pipelinegraphanalysis.TimingInfo) StepEndNode(org.jenkinsci.plugins.workflow.cps.nodes.StepEndNode) IOException(java.io.IOException) StepAtomNode(org.jenkinsci.plugins.workflow.cps.nodes.StepAtomNode) InputStepExecution(org.jenkinsci.plugins.workflow.support.steps.input.InputStepExecution) InputStep(org.jenkinsci.plugins.workflow.support.steps.input.InputStep) FlowNode(org.jenkinsci.plugins.workflow.graph.FlowNode) TimeoutException(java.util.concurrent.TimeoutException)

Example 2 with StepEndNode

use of org.jenkinsci.plugins.workflow.cps.nodes.StepEndNode in project blueocean-plugin by jenkinsci.

the class PipelineNodeGraphVisitor method chunkEnd.

@Override
public void chunkEnd(@Nonnull FlowNode endNode, @CheckForNull FlowNode afterBlock, @Nonnull ForkScanner scanner) {
    super.chunkEnd(endNode, afterBlock, scanner);
    if (isNodeVisitorDumpEnabled)
        dump(String.format("chunkEnd=> id: %s, name: %s, function: %s, type:%s", endNode.getId(), endNode.getDisplayName(), endNode.getDisplayFunctionName(), endNode.getClass()));
    if (isNodeVisitorDumpEnabled && endNode instanceof StepEndNode) {
        dump("\tStartNode: " + ((StepEndNode) endNode).getStartNode());
    }
    if (endNode instanceof StepStartNode) {
        if (endNode.getDisplayFunctionName().equals("node")) {
            agentNode = (StepStartNode) endNode;
        }
    }
    // capture orphan branches
    captureOrphanParallelBranches();
    //if block stage node push it to stack as it may have nested stages
    if (parallelEnd == null && endNode instanceof StepEndNode && //skip synthetic stages
    !PipelineNodeUtil.isSyntheticStage(((StepEndNode) endNode).getStartNode()) && PipelineNodeUtil.isStage(((StepEndNode) endNode).getStartNode())) {
        //XXX: There seems to be bug in eventing, chunkEnd is sent twice for the same FlowNode
        //     Lets peek and if the last one is same as this endNode then skip adding it
        FlowNode node = null;
        if (!nestedStages.empty()) {
            node = nestedStages.peek();
        }
        if (node == null || !node.equals(endNode)) {
            nestedStages.push(endNode);
        }
    }
    firstExecuted = null;
    // if we're using marker-based (and not block-scoped) stages, add the last node as part of its contents
    if (!(endNode instanceof BlockEndNode)) {
        atomNode(null, endNode, afterBlock, scanner);
    }
}
Also used : StepStartNode(org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode) StepEndNode(org.jenkinsci.plugins.workflow.cps.nodes.StepEndNode) BlockEndNode(org.jenkinsci.plugins.workflow.graph.BlockEndNode) FlowNode(org.jenkinsci.plugins.workflow.graph.FlowNode)

Aggregations

StepEndNode (org.jenkinsci.plugins.workflow.cps.nodes.StepEndNode)2 FlowNode (org.jenkinsci.plugins.workflow.graph.FlowNode)2 IOException (java.io.IOException)1 TimeoutException (java.util.concurrent.TimeoutException)1 StepAtomNode (org.jenkinsci.plugins.workflow.cps.nodes.StepAtomNode)1 StepStartNode (org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode)1 BlockEndNode (org.jenkinsci.plugins.workflow.graph.BlockEndNode)1 TimingInfo (org.jenkinsci.plugins.workflow.pipelinegraphanalysis.TimingInfo)1 InputStep (org.jenkinsci.plugins.workflow.support.steps.input.InputStep)1 InputStepExecution (org.jenkinsci.plugins.workflow.support.steps.input.InputStepExecution)1