Search in sources :

Example 1 with StageChunkFinder

use of org.jenkinsci.plugins.workflow.pipelinegraphanalysis.StageChunkFinder in project blueocean-plugin by jenkinsci.

the class PipelineNodeGraphVisitor method getPipelineNodeSteps.

@Override
public List<BluePipelineStep> getPipelineNodeSteps(final String nodeId, Link parent) {
    FlowExecution execution = run.getExecution();
    if (execution == null) {
        logger.debug(String.format("Pipeline %s, runid %s  has null execution", run.getParent().getName(), run.getId()));
        return Collections.emptyList();
    }
    DepthFirstScanner depthFirstScanner = new DepthFirstScanner();
    // If blocked scope, get the end node
    FlowNode n = depthFirstScanner.findFirstMatch(execution.getCurrentHeads(), input -> (input != null && input.getId().equals(nodeId) && (PipelineNodeUtil.isStage(input) || PipelineNodeUtil.isParallelBranch(input))));
    if (n == null) {
        // if no node found or the node is not stage or parallel we return empty steps
        return Collections.emptyList();
    }
    PipelineStepVisitor visitor = new PipelineStepVisitor(run, n);
    ForkScanner.visitSimpleChunks(execution.getCurrentHeads(), visitor, new StageChunkFinder());
    return visitor.getSteps().stream().map(node -> new PipelineStepImpl(node, parent)).collect(Collectors.toList());
}
Also used : DepthFirstScanner(org.jenkinsci.plugins.workflow.graphanalysis.DepthFirstScanner) Arrays(java.util.Arrays) InputAction(org.jenkinsci.plugins.workflow.support.steps.input.InputAction) LoggerFactory(org.slf4j.LoggerFactory) LabelAction(org.jenkinsci.plugins.workflow.actions.LabelAction) StringUtils(org.apache.commons.lang3.StringUtils) GenericStatus(org.jenkinsci.plugins.workflow.pipelinegraphanalysis.GenericStatus) MemoryFlowChunk(org.jenkinsci.plugins.workflow.graphanalysis.MemoryFlowChunk) Map(java.util.Map) ExecutionModelAction(org.jenkinsci.plugins.pipeline.modeldefinition.actions.ExecutionModelAction) FlowExecution(org.jenkinsci.plugins.workflow.flow.FlowExecution) BluePipelineNode(io.jenkins.blueocean.rest.model.BluePipelineNode) Action(hudson.model.Action) Collection(java.util.Collection) Set(java.util.Set) Collectors(java.util.stream.Collectors) StepStartNode(org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode) List(java.util.List) PauseAction(org.jenkinsci.plugins.workflow.support.actions.PauseAction) Optional(java.util.Optional) FlowStartNode(org.jenkinsci.plugins.workflow.graph.FlowStartNode) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun) Link(io.jenkins.blueocean.rest.hal.Link) FlowNode(org.jenkinsci.plugins.workflow.graph.FlowNode) TimingAction(org.jenkinsci.plugins.workflow.actions.TimingAction) HashMap(java.util.HashMap) Stack(java.util.Stack) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) TimingInfo(org.jenkinsci.plugins.workflow.pipelinegraphanalysis.TimingInfo) BlockEndNode(org.jenkinsci.plugins.workflow.graph.BlockEndNode) StandardChunkVisitor(org.jenkinsci.plugins.workflow.graphanalysis.StandardChunkVisitor) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) StageChunkFinder(org.jenkinsci.plugins.workflow.pipelinegraphanalysis.StageChunkFinder) StatusAndTiming(org.jenkinsci.plugins.workflow.pipelinegraphanalysis.StatusAndTiming) BluePipelineStep(io.jenkins.blueocean.rest.model.BluePipelineStep) BlueRun(io.jenkins.blueocean.rest.model.BlueRun) NotExecutedNodeAction(org.jenkinsci.plugins.workflow.actions.NotExecutedNodeAction) IOException(java.io.IOException) ForkScanner(org.jenkinsci.plugins.workflow.graphanalysis.ForkScanner) StepAtomNode(org.jenkinsci.plugins.workflow.cps.nodes.StepAtomNode) StepEndNode(org.jenkinsci.plugins.workflow.cps.nodes.StepEndNode) ArrayDeque(java.util.ArrayDeque) Comparator(java.util.Comparator) CheckForNull(javax.annotation.CheckForNull) Collections(java.util.Collections) StageChunkFinder(org.jenkinsci.plugins.workflow.pipelinegraphanalysis.StageChunkFinder) FlowExecution(org.jenkinsci.plugins.workflow.flow.FlowExecution) DepthFirstScanner(org.jenkinsci.plugins.workflow.graphanalysis.DepthFirstScanner) FlowNode(org.jenkinsci.plugins.workflow.graph.FlowNode)

Example 2 with StageChunkFinder

use of org.jenkinsci.plugins.workflow.pipelinegraphanalysis.StageChunkFinder in project blueocean-plugin by jenkinsci.

the class PipelineNodeGraphVisitor method getPipelineNodeStep.

@Override
public BluePipelineStep getPipelineNodeStep(String id, Link parent) {
    FlowExecution execution = run.getExecution();
    if (execution == null) {
        return null;
    }
    PipelineStepVisitor visitor = new PipelineStepVisitor(run, null);
    ForkScanner.visitSimpleChunks(execution.getCurrentHeads(), visitor, new StageChunkFinder());
    FlowNodeWrapper node = visitor.getStep(id);
    if (node == null) {
        return null;
    }
    return new PipelineStepImpl(node, parent);
}
Also used : StageChunkFinder(org.jenkinsci.plugins.workflow.pipelinegraphanalysis.StageChunkFinder) FlowExecution(org.jenkinsci.plugins.workflow.flow.FlowExecution)

Example 3 with StageChunkFinder

use of org.jenkinsci.plugins.workflow.pipelinegraphanalysis.StageChunkFinder in project blueocean-plugin by jenkinsci.

the class PipelineBaseTest method getAllSteps.

protected List<FlowNode> getAllSteps(WorkflowRun run) {
    PipelineStepVisitor visitor = new PipelineStepVisitor(run, null);
    ForkScanner.visitSimpleChunks(run.getExecution().getCurrentHeads(), visitor, new StageChunkFinder());
    List<FlowNode> steps = new ArrayList<>();
    for (FlowNodeWrapper node : visitor.getSteps()) {
        steps.add(node.getNode());
    }
    return steps;
}
Also used : StageChunkFinder(org.jenkinsci.plugins.workflow.pipelinegraphanalysis.StageChunkFinder) ArrayList(java.util.ArrayList) FlowNode(org.jenkinsci.plugins.workflow.graph.FlowNode)

Example 4 with StageChunkFinder

use of org.jenkinsci.plugins.workflow.pipelinegraphanalysis.StageChunkFinder in project blueocean-plugin by jenkinsci.

the class PipelineNodeGraphVisitor method getPipelineNodeSteps.

@Override
public List<BluePipelineStep> getPipelineNodeSteps(Link parent) {
    FlowExecution execution = run.getExecution();
    if (execution == null) {
        return Collections.emptyList();
    }
    PipelineStepVisitor visitor = new PipelineStepVisitor(run, null);
    ForkScanner.visitSimpleChunks(execution.getCurrentHeads(), visitor, new StageChunkFinder());
    return visitor.getSteps().stream().map(node -> new PipelineStepImpl(node, parent)).collect(Collectors.toList());
}
Also used : DepthFirstScanner(org.jenkinsci.plugins.workflow.graphanalysis.DepthFirstScanner) Arrays(java.util.Arrays) InputAction(org.jenkinsci.plugins.workflow.support.steps.input.InputAction) LoggerFactory(org.slf4j.LoggerFactory) LabelAction(org.jenkinsci.plugins.workflow.actions.LabelAction) StringUtils(org.apache.commons.lang3.StringUtils) GenericStatus(org.jenkinsci.plugins.workflow.pipelinegraphanalysis.GenericStatus) MemoryFlowChunk(org.jenkinsci.plugins.workflow.graphanalysis.MemoryFlowChunk) Map(java.util.Map) ExecutionModelAction(org.jenkinsci.plugins.pipeline.modeldefinition.actions.ExecutionModelAction) FlowExecution(org.jenkinsci.plugins.workflow.flow.FlowExecution) BluePipelineNode(io.jenkins.blueocean.rest.model.BluePipelineNode) Action(hudson.model.Action) Collection(java.util.Collection) Set(java.util.Set) Collectors(java.util.stream.Collectors) StepStartNode(org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode) List(java.util.List) PauseAction(org.jenkinsci.plugins.workflow.support.actions.PauseAction) Optional(java.util.Optional) FlowStartNode(org.jenkinsci.plugins.workflow.graph.FlowStartNode) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun) Link(io.jenkins.blueocean.rest.hal.Link) FlowNode(org.jenkinsci.plugins.workflow.graph.FlowNode) TimingAction(org.jenkinsci.plugins.workflow.actions.TimingAction) HashMap(java.util.HashMap) Stack(java.util.Stack) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) TimingInfo(org.jenkinsci.plugins.workflow.pipelinegraphanalysis.TimingInfo) BlockEndNode(org.jenkinsci.plugins.workflow.graph.BlockEndNode) StandardChunkVisitor(org.jenkinsci.plugins.workflow.graphanalysis.StandardChunkVisitor) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) StageChunkFinder(org.jenkinsci.plugins.workflow.pipelinegraphanalysis.StageChunkFinder) StatusAndTiming(org.jenkinsci.plugins.workflow.pipelinegraphanalysis.StatusAndTiming) BluePipelineStep(io.jenkins.blueocean.rest.model.BluePipelineStep) BlueRun(io.jenkins.blueocean.rest.model.BlueRun) NotExecutedNodeAction(org.jenkinsci.plugins.workflow.actions.NotExecutedNodeAction) IOException(java.io.IOException) ForkScanner(org.jenkinsci.plugins.workflow.graphanalysis.ForkScanner) StepAtomNode(org.jenkinsci.plugins.workflow.cps.nodes.StepAtomNode) StepEndNode(org.jenkinsci.plugins.workflow.cps.nodes.StepEndNode) ArrayDeque(java.util.ArrayDeque) Comparator(java.util.Comparator) CheckForNull(javax.annotation.CheckForNull) Collections(java.util.Collections) StageChunkFinder(org.jenkinsci.plugins.workflow.pipelinegraphanalysis.StageChunkFinder) FlowExecution(org.jenkinsci.plugins.workflow.flow.FlowExecution)

Aggregations

StageChunkFinder (org.jenkinsci.plugins.workflow.pipelinegraphanalysis.StageChunkFinder)4 ArrayList (java.util.ArrayList)3 FlowExecution (org.jenkinsci.plugins.workflow.flow.FlowExecution)3 FlowNode (org.jenkinsci.plugins.workflow.graph.FlowNode)3 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 Action (hudson.model.Action)2 Link (io.jenkins.blueocean.rest.hal.Link)2 BluePipelineNode (io.jenkins.blueocean.rest.model.BluePipelineNode)2 BluePipelineStep (io.jenkins.blueocean.rest.model.BluePipelineStep)2 BlueRun (io.jenkins.blueocean.rest.model.BlueRun)2 IOException (java.io.IOException)2 ArrayDeque (java.util.ArrayDeque)2 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 Comparator (java.util.Comparator)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 LinkedHashMap (java.util.LinkedHashMap)2