org.jenkinsci.plugins.workflow.graph.FlowNode Java Examples

The following examples show how to use org.jenkinsci.plugins.workflow.graph.FlowNode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PipelineStepVisitor.java    From blueocean-plugin with MIT License 6 votes vote down vote up
@Override
public void chunkEnd(@Nonnull FlowNode endNode, @CheckForNull FlowNode afterChunk, @Nonnull ForkScanner scanner) {
    super.chunkEnd(endNode, afterChunk, scanner);
    if(endNode instanceof StepEndNode && PipelineNodeUtil.isStage(((StepEndNode)endNode).getStartNode())){
        currentStage = ((StepEndNode)endNode).getStartNode();
    } else {
        final String id = endNode.getEnclosingId();
        currentStage = endNode.getEnclosingBlocks().stream()
                .filter((block) -> block.getId().equals(id))
                .findFirst()
                .orElse(null);
    }
    if(node!= null && endNode instanceof StepEndNode && ((StepEndNode)endNode).getStartNode().equals(node)){
        this.stageStepsCollectionCompleted = false;
        this.inStageScope = true;
    }

    if (endNode instanceof StepStartNode && PipelineNodeUtil.isAgentStart(endNode)) {
        agentNode = (StepStartNode) endNode;
    }

    // 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, afterChunk, scanner);
    }
}
 
Example #2
Source File: LinkResolverImpl.java    From blueocean-plugin with MIT License 6 votes vote down vote up
@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;
}
 
Example #3
Source File: PipelineNodeUtil.java    From blueocean-plugin with MIT License 6 votes vote down vote up
/**
 * Determine if the given {@link FlowNode} is the initial {@link StepStartNode} for an {@link org.jenkinsci.plugins.workflow.support.steps.ExecutorStep}.
 *
 * @param node a possibly null {@link FlowNode}
 * @return true if {@code node} is the non-body start of the agent execution.
 */
public static boolean isAgentStart(@Nullable FlowNode node) {
    if (node != null) {
        if (node instanceof StepStartNode) {
            StepStartNode stepStartNode = (StepStartNode) node;
            if (stepStartNode.getDescriptor() != null) {
                StepDescriptor sd = stepStartNode.getDescriptor();
                return sd != null &&
                    ExecutorStep.DescriptorImpl.class.equals(sd.getClass()) &&
                    !stepStartNode.isBody();
            }
        }
    }

    return false;
}
 
Example #4
Source File: PipelineNodeUtil.java    From blueocean-plugin with MIT License 6 votes vote down vote up
/**
 *  Gives cause of block for declarative style plugin where agent (node block) is declared inside a stage.
 *  <pre>
 *    pipeline {
 *      agent none
 *      stages {
 *          stage ('first') {
 *              agent {
 *                  label 'first'
 *              }
 *              steps{
 *                  sh 'echo "from first"'
 *              }
 *          }
 *      }
 *    }
 *  </pre>
 *
 * @param stage stage's {@link FlowNode}
 * @param nodeBlock agent or node block's {@link FlowNode}
 * @return cause of block if present, nul otherwise
 */
public static @CheckForNull String getCauseOfBlockage(@Nonnull FlowNode stage, @Nullable FlowNode nodeBlock) {
    if(nodeBlock != null){
        //Check and see if this node block is inside this stage
        for(FlowNode p:nodeBlock.getParents()){
            if(p.equals(stage)){
                Queue.Item item = QueueItemAction.getQueueItem(nodeBlock);
                if (item != null) {
                    CauseOfBlockage causeOfBlockage = item.getCauseOfBlockage();
                    String cause = null;
                    if (causeOfBlockage != null) {
                        cause = causeOfBlockage.getShortDescription();
                        if (cause == null) {
                            causeOfBlockage = item.task.getCauseOfBlockage();
                            if(causeOfBlockage != null) {
                                return causeOfBlockage.getShortDescription();
                            }
                        }
                    }
                    return cause;
                }
            }
        }
    }
    return null;
}
 
Example #5
Source File: PipelineStepVisitor.java    From blueocean-plugin with MIT License 6 votes vote down vote up
@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;
        final String cause = PipelineNodeUtil.getCauseOfBlockage(chunk.getFirstNode(), agentNode);
        if(cause != null) {
            // TODO: This should probably be changed (elsewhere?) to instead just render this directly, not via a fake step.
            //Now add a step that indicates blockage cause
            FlowNode step = new LocalAtomNode(chunk, 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);
        }
    }if(node != null && PipelineNodeUtil.isStage(node) && !inStageScope && !chunk.getFirstNode().equals(node)){
        resetSteps();
    }
}
 
Example #6
Source File: DockerNodeStepExecution.java    From docker-plugin with MIT License 6 votes vote down vote up
private void invokeBody(DockerTransientNode node, TaskListener listener) {
    this.nodeName = node.getNodeName();
    FilePath ws = null;
    Computer computer = null;
    EnvVars env = null;
    try {
        // TODO workspace should be a volume
        ws = node.createPath(node.getRemoteFS() + "/workspace");
        FlowNode flowNode = getContext().get(FlowNode.class);
        flowNode.addAction(new WorkspaceActionImpl(ws, flowNode));

        computer = node.toComputer();
        if (computer == null) throw new IllegalStateException("Agent not started");
        env = computer.getEnvironment();
        env.overrideExpandingAll(computer.buildEnvironment(listener));
        env.put("NODE_NAME", computer.getName());
        env.put("EXECUTOR_NUMBER", "0");
        env.put("NODE_LABELS", Util.join(node.getAssignedLabels(), " "));
        env.put("WORKSPACE", ws.getRemote());
    } catch (IOException | InterruptedException e) {
        getContext().onFailure(e);
    }

    getContext().newBodyInvoker().withCallback(new Callback(node)).withContexts(computer, env, ws).start();
}
 
Example #7
Source File: PipelineNodeGraphVisitor.java    From blueocean-plugin with MIT License 6 votes vote down vote up
@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());
}
 
Example #8
Source File: KubernetesDeclarativeAgentTest.java    From kubernetes-plugin with Apache License 2.0 6 votes vote down vote up
@Issue({"JENKINS-41758", "JENKINS-57827", "JENKINS-60886"})
@Test
public void declarative() throws Exception {
    assertNotNull(createJobThenScheduleRun());
    r.assertBuildStatusSuccess(r.waitForCompletion(b));
    r.assertLogContains("Apache Maven 3.3.9", b);
    r.assertLogContains("INSIDE_CONTAINER_ENV_VAR = " + CONTAINER_ENV_VAR_VALUE + "\n", b);
    r.assertLogContains("OUTSIDE_CONTAINER_ENV_VAR = " + CONTAINER_ENV_VAR_VALUE + "\n", b);
    FlowNode podTemplateNode = new DepthFirstScanner().findFirstMatch(b.getExecution(), Predicates.and(new NodeStepTypePredicate("podTemplate"), FlowScanningUtils.hasActionPredicate(ArgumentsAction.class)));
    assertNotNull("recorded arguments for podTemplate", podTemplateNode);
    Map<String, Object> arguments = podTemplateNode.getAction(ArgumentsAction.class).getArguments();
    @SuppressWarnings("unchecked")
    List<UninstantiatedDescribable> containers = (List<UninstantiatedDescribable>) arguments.get("containers");
    assertNotNull(containers);
    assertFalse("no junk in arguments: " + arguments, containers.get(0).getArguments().containsKey("alwaysPullImage"));
    FlowNode containerNode = new DepthFirstScanner().findFirstMatch(b.getExecution(), Predicates.and(new NodeStepTypePredicate("container"), FlowScanningUtils.hasActionPredicate(ArgumentsAction.class)));
    assertNotNull("recorded arguments for container", containerNode);
    // JENKINS-60886
    UninstantiatedDescribable podRetention = (UninstantiatedDescribable) arguments.get("podRetention");
    assertNotNull(podRetention);
    assertTrue(podRetention.getModel().getType().equals(OnFailure.class));
}
 
Example #9
Source File: PipelineEventListenerTest.java    From blueocean-plugin with MIT License 6 votes vote down vote up
@Test
public void testParentNodesOrder() throws Exception {
    String script = "node {\n" +
            "    stage('one') {\n" +
            "        sh \"echo 42\"        \n" +
            "        parallel('branch1':{\n" +
            "          sh 'echo \"branch1\"'\n" +
            "        }, 'branch2': {\n" +
            "          sh 'echo \"branch2\"'\n" +
            "        })\n" +
            "    }\n" +
            "\n" +
            "}";
    WorkflowJob job1 = j.jenkins.createProject(WorkflowJob.class, "pipeline1");
    job1.setDefinition(new CpsFlowDefinition(script));
    WorkflowRun b1 = job1.scheduleBuild2(0).get();
    j.assertBuildStatus(Result.SUCCESS, b1);

    List<FlowNode> parallels = getParallelNodes(NodeGraphBuilder.NodeGraphBuilderFactory.getInstance(b1));
    Assert.assertEquals("10", parallels.get(0).getId());
    Assert.assertEquals("Branch: branch1", parallels.get(0).getDisplayName());

    Assert.assertEquals(Lists.newArrayList("2","3","4","5","6","8"),
            new PipelineEventListener().getBranch(parallels.get(0)));
}
 
Example #10
Source File: FlowNodeWrapper.java    From blueocean-plugin with MIT License 5 votes vote down vote up
public FlowNodeWrapper(@Nonnull FlowNode node, @Nonnull NodeRunStatus status,
                       @Nonnull TimingInfo timingInfo, @Nullable InputStep inputStep, @Nonnull WorkflowRun run) {
    this.node = node;
    this.status = status;
    this.timingInfo = timingInfo;
    this.type = getNodeType(node);
    this.displayName = PipelineNodeUtil.getDisplayName(node);
    this.inputStep = inputStep;
    this.run = run;
}
 
Example #11
Source File: PipelineNodeGraphVisitor.java    From blueocean-plugin with MIT License 5 votes vote down vote up
@Override
public void parallelBranchStart(@Nonnull FlowNode parallelStartNode, @Nonnull FlowNode branchStartNode, @Nonnull ForkScanner scanner) {
    if (isNodeVisitorDumpEnabled) {
        dump(String.format("parallelBranchStart=> id: %s, name: %s, function: %s", branchStartNode.getId(),
                           branchStartNode.getDisplayName(), branchStartNode.getDisplayFunctionName()));
    }

    // Save actions for this branch, so we can add them to the FlowNodeWrapper later
    pendingActionsForBranches.put(branchStartNode, drainPipelineActions());
    nestedbranches.push(branchStartNode);
    if (!pendingBranchEndNodes.isEmpty()) {
        FlowNode endNode = pendingBranchEndNodes.pop();
        parallelBranchEndNodes.add(endNode);
    }
}
 
Example #12
Source File: PipelineNodeGraphVisitor.java    From blueocean-plugin with MIT License 5 votes vote down vote up
@Override
public void parallelEnd(@Nonnull FlowNode parallelStartNode, @Nonnull FlowNode parallelEndNode, @Nonnull ForkScanner scanner) {
    if (isNodeVisitorDumpEnabled) {
        dump(String.format("parallelEnd=> id: %s, name: %s, function: %s", parallelEndNode.getId(),
                           parallelEndNode.getDisplayName(), parallelEndNode.getDisplayFunctionName()));
        if (parallelEndNode instanceof StepEndNode) {
            dump(String.format("parallelEnd=> id: %s, StartNode: %s, name: %s, function: %s", parallelEndNode.getId(),
                               ((StepEndNode) parallelEndNode).getStartNode().getId(), ((StepEndNode) parallelEndNode).getStartNode().getDisplayName(), ((StepEndNode) parallelEndNode).getStartNode().getDisplayFunctionName()));
        }
    }
    captureOrphanParallelBranches();
    this.parallelEnds.add(parallelEndNode);
}
 
Example #13
Source File: JUnitResultsStepExecution.java    From junit-plugin with MIT License 5 votes vote down vote up
@Nonnull
public static List<String> getEnclosingBlockIds(@Nonnull List<FlowNode> nodes) {
    List<String> ids = new ArrayList<>();
    for (FlowNode n : nodes) {
        ids.add(n.getId());
    }
    return ids;
}
 
Example #14
Source File: NodeRunStatus.java    From blueocean-plugin with MIT License 5 votes vote down vote up
public NodeRunStatus(@Nonnull FlowNode endNode) {
    Result result = null;
    ErrorAction errorAction = endNode.getError();
    WarningAction warningAction = endNode.getPersistentAction(WarningAction.class);
    if (errorAction != null) {
        if(errorAction.getError() instanceof FlowInterruptedException) {
            result = ((FlowInterruptedException) errorAction.getError()).getResult();
        }
        if(result == null || result != Result.ABORTED) {
            this.result = BlueRun.BlueRunResult.FAILURE;
        } else {
            this.result = BlueRun.BlueRunResult.ABORTED;
        }
        this.state = endNode.isActive() ? BlueRun.BlueRunState.RUNNING : BlueRun.BlueRunState.FINISHED;
    } else if (warningAction != null) {
        this.result = new NodeRunStatus(GenericStatus.fromResult(warningAction.getResult())).result;
        this.state = endNode.isActive() ? BlueRun.BlueRunState.RUNNING : BlueRun.BlueRunState.FINISHED;
    } else if (QueueItemAction.getNodeState(endNode) == QueueItemAction.QueueState.QUEUED) {
        this.result = BlueRun.BlueRunResult.UNKNOWN;
        this.state = BlueRun.BlueRunState.QUEUED;
    } else if (QueueItemAction.getNodeState(endNode) == QueueItemAction.QueueState.CANCELLED) {
        this.result = BlueRun.BlueRunResult.ABORTED;
        this.state = BlueRun.BlueRunState.FINISHED;
    } else if (endNode.isActive()) {
        this.result = BlueRun.BlueRunResult.UNKNOWN;
        this.state = BlueRun.BlueRunState.RUNNING;
    } else if (NotExecutedNodeAction.isExecuted(endNode)) {
        this.result = BlueRun.BlueRunResult.SUCCESS;
        this.state = BlueRun.BlueRunState.FINISHED;
    } else {
        this.result = BlueRun.BlueRunResult.NOT_BUILT;
        this.state = BlueRun.BlueRunState.QUEUED;
    }
}
 
Example #15
Source File: FlowNodeWrapper.java    From blueocean-plugin with MIT License 5 votes vote down vote up
private static NodeType getNodeType(FlowNode node) {
    if (PipelineNodeUtil.isStage(node)) {
        return NodeType.STAGE;
    } else if (PipelineNodeUtil.isParallelBranch(node)) {
        return NodeType.PARALLEL;
    } else if (node instanceof AtomNode) {
        return NodeType.STEP;
    }
    throw new IllegalArgumentException(String.format("Unknown FlowNode %s, type: %s", node.getId(), node.getClass()));
}
 
Example #16
Source File: PipelineBaseTest.java    From blueocean-plugin with MIT License 5 votes vote down vote up
protected List<FlowNode> getParallelNodes(FlowGraphTable nodeGraphTable){
    List<FlowNode> parallelNodes = new ArrayList<>();

    for(FlowGraphTable.Row row: nodeGraphTable.getRows()){
        if(PipelineNodeUtil.isParallelBranch(row.getNode())){
            parallelNodes.add(row.getNode());
        }
    }
    return parallelNodes;
}
 
Example #17
Source File: PipelineStepVisitor.java    From blueocean-plugin with MIT License 5 votes vote down vote up
public List<FlowNodeWrapper> getSteps(){
    List<FlowNodeWrapper> s = new ArrayList<>();
    if(node != null){
        if(PipelineNodeUtil.isSkippedStage(node)){
            return Collections.emptyList();
        }
        FlowNode first=null;
        FlowNode last=null;
        if(!stages.isEmpty()) {
            first = stages.getFirst();
            last = stages.getLast();
        }

        if(first!= null && node.equals(first)){
            s.addAll(preSteps);
        }
        s.addAll(steps);
        if(last!= null && (node.equals(last) || PipelineNodeUtil.isSkippedStage(last))){
            s.addAll(postSteps);
        }

    }else {
        s.addAll(preSteps);
        s.addAll(steps);
        s.addAll(postSteps);
    }
    return s;
}
 
Example #18
Source File: LockStepTestBase.java    From lockable-resources-plugin with MIT License 5 votes vote down vote up
protected void isPaused(WorkflowRun run, int count, int effectivePauses) {
  int pauseActions = 0, pausedActions = 0;
  for (FlowNode node : new FlowGraphWalker(run.getExecution())) {
    for (PauseAction pauseAction : PauseAction.getPauseActions(node)) {
      ++pauseActions;
      if (pauseAction.isPaused()) {
        ++pausedActions;
      }
    }
  }
  assertEquals(count, pauseActions);
  assertEquals(effectivePauses, pausedActions);
}
 
Example #19
Source File: PipelineNodeGraphVisitor.java    From blueocean-plugin with MIT License 5 votes vote down vote up
@Override
public void parallelBranchEnd(@Nonnull FlowNode parallelStartNode, @Nonnull FlowNode branchEndNode, @Nonnull ForkScanner scanner) {
    if (isNodeVisitorDumpEnabled) {
        dump(String.format("parallelBranchEnd=> id: %s, name: %s, function: %s, type: %s", branchEndNode.getId(),
                           branchEndNode.getDisplayName(), branchEndNode.getDisplayFunctionName(), branchEndNode.getClass()));
        if (branchEndNode instanceof StepEndNode) {
            dump(String.format("parallelBranchEnd=> id: %s, StartNode: %s, name: %s, function: %s", branchEndNode.getId(),
                               ((StepEndNode) branchEndNode).getStartNode().getId(), ((StepEndNode) branchEndNode).getStartNode().getDisplayName(),
                               ((StepEndNode) branchEndNode).getStartNode().getDisplayFunctionName()));
        }
    }
    pendingBranchEndNodes.add(branchEndNode);
    parallelBranchStartNodes.add(parallelStartNode);
}
 
Example #20
Source File: PipelineNodeGraphVisitor.java    From blueocean-plugin with MIT License 5 votes vote down vote up
/**
 * Find any Actions on this node, and add them to the pipelineActions collection until we can attach
 * them to a FlowNodeWrapper.
 */
protected void accumulatePipelineActions(FlowNode node) {
    final List<Action> actions = node.getActions(Action.class);
    pipelineActions.addAll(actions);
    if (isNodeVisitorDumpEnabled) {
        dump(String.format("\t\taccumulating actions - added %d, total is %d", actions.size(), pipelineActions.size()));
    }
}
 
Example #21
Source File: JUnitResultsStepTest.java    From junit-plugin with MIT License 5 votes vote down vote up
@Issue("JENKINS-48250")
@Test
public void emptyFails() throws Exception {
    WorkflowJob j = rule.jenkins.createProject(WorkflowJob.class, "emptyFails");
    j.setDefinition(new CpsFlowDefinition("stage('first') {\n" +
            "  node {\n" +
            (Functions.isWindows() ?
            "    bat 'echo hi'\n" :
            "    sh 'echo hi'\n") +
            "    junit('*.xml')\n" +
            "  }\n" +
            "}\n", true));

    WorkflowRun r = j.scheduleBuild2(0).waitForStart();
    rule.assertBuildStatus(Result.FAILURE, rule.waitForCompletion(r));
    rule.assertLogContains("ERROR: " + Messages.JUnitResultArchiver_NoTestReportFound(), r);
    FlowExecution execution = r.getExecution();
    DepthFirstScanner scanner = new DepthFirstScanner();
    FlowNode f = scanner.findFirstMatch(execution, new Predicate<FlowNode>() {
        @Override
        public boolean apply(@Nullable FlowNode input) {
            return input instanceof StepAtomNode &&
                    ((StepAtomNode) input).getDescriptor() instanceof JUnitResultsStep.DescriptorImpl;
        }
    });
    assertNotNull(f);
    LogAction logAction = f.getPersistentAction(LogAction.class);
    assertNotNull(logAction);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    logAction.getLogText().writeRawLogTo(0, baos);
    String log = baos.toString();
    assertThat(log, CoreMatchers.containsString(Messages.JUnitResultArchiver_NoTestReportFound()));
}
 
Example #22
Source File: PipelineNodeUtil.java    From blueocean-plugin with MIT License 5 votes vote down vote up
@Nonnull
public static String getDisplayName(@Nonnull FlowNode node) {
    ThreadNameAction threadNameAction = node.getAction(ThreadNameAction.class);
    return threadNameAction != null
        ? threadNameAction.getThreadName()
        : node.getDisplayName();
}
 
Example #23
Source File: JUnitResultsStepExecution.java    From junit-plugin with MIT License 5 votes vote down vote up
private static boolean isStageNode(@Nonnull FlowNode node) {
    if (node instanceof StepNode) {
        StepDescriptor d = ((StepNode) node).getDescriptor();
        return d != null && d.getFunctionName().equals("stage");
    } else {
        return false;
    }
}
 
Example #24
Source File: PipelineNodeUtil.java    From blueocean-plugin with MIT License 5 votes vote down vote up
@CheckForNull
public static TagsAction getSyntheticStage(@Nullable FlowNode node){
    if(node != null) {
        for (Action action : node.getActions()) {
            if (action instanceof TagsAction && ((TagsAction) action).getTagValue(SyntheticStage.TAG_NAME) != null) {
                return (TagsAction) action;
            }
        }
    }
    return null;
}
 
Example #25
Source File: PipelineNodeUtil.java    From blueocean-plugin with MIT License 5 votes vote down vote up
public static boolean isPostSyntheticStage(@Nullable FlowNode node){
    if(node == null){
        return false;
    }
    TagsAction tagsAction = getSyntheticStage(node);
    if(tagsAction == null){
        return false;
    }
    String value = tagsAction.getTagValue(SyntheticStage.TAG_NAME);
    return value!=null && value.equals(SyntheticStage.getPost());
}
 
Example #26
Source File: JUnitResultsStepTest.java    From junit-plugin with MIT License 5 votes vote down vote up
private static Predicate<FlowNode> branchForName(final String name) {
    return new Predicate<FlowNode>() {
        @Override
        public boolean apply(@Nullable FlowNode input) {
            return input != null &&
                    input.getAction(LabelAction.class) != null &&
                    input.getAction(ThreadNameAction.class) != null &&
                    name.equals(input.getAction(ThreadNameAction.class).getThreadName());
        }
    };
}
 
Example #27
Source File: PipelineNodeUtil.java    From blueocean-plugin with MIT License 5 votes vote down vote up
public static boolean isPreSyntheticStage(@Nullable FlowNode node){
    if(node == null){
        return false;
    }
    TagsAction tagsAction = getSyntheticStage(node);
    if(tagsAction == null){
        return false;
    }
    String value = tagsAction.getTagValue(SyntheticStage.TAG_NAME);
    return value!=null && value.equals(SyntheticStage.getPre());
}
 
Example #28
Source File: PipelineBaseTest.java    From blueocean-plugin with MIT License 5 votes vote down vote up
protected List<FlowNode> getStagesAndParallels(NodeGraphBuilder builder){
    return builder.getPipelineNodes().stream()
        .filter( nodeWrapper -> nodeWrapper.type == FlowNodeWrapper.NodeType.PARALLEL || nodeWrapper.type == FlowNodeWrapper.NodeType.STAGE)
        .map( nodeWrapper -> nodeWrapper.getNode() )
        .collect( Collectors.toList() );

}
 
Example #29
Source File: LinkResolverImpl.java    From blueocean-plugin with MIT License 5 votes vote down vote up
private BlueRun resolveFlowNodeRun(FlowNode flowNode) {
    try {
        Queue.Executable executable = flowNode.getExecution().getOwner().getExecutable();
        if (executable != null && executable instanceof WorkflowRun) {
            WorkflowRun run = (WorkflowRun) executable;
            return (BlueRun) resolveRun(run);
        }
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
        return null;

    }
    return null;
}
 
Example #30
Source File: PipelineBaseTest.java    From blueocean-plugin with MIT License 5 votes vote down vote up
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;
}