Search in sources :

Example 1 with NodeDownstreamBuildAction

use of io.jenkins.blueocean.listeners.NodeDownstreamBuildAction in project blueocean-plugin by jenkinsci.

the class GraphBuilderTest method downstreamBuildLinksDecl.

@Test
public void downstreamBuildLinksDecl() throws Exception {
    // Any simple pipeline would do for these
    createJob("downstream1", "declarativeQueuedAgent.jenkinsfile");
    createJob("downstream2", "declarativeQueuedAgent.jenkinsfile");
    WorkflowRun run = createAndRunJob("downstreamBuildLinksDecl", "downstreamBuildLinksDecl.jenkinsfile");
    NodeGraphBuilder graph = NodeGraphBuilder.NodeGraphBuilderFactory.getInstance(run);
    List<FlowNodeWrapper> nodes = graph.getPipelineNodes();
    assertStageAndEdges(nodes, "Stage the first", "Stage the second");
    assertStageAndEdges(nodes, "Stage the second", "downstream1", "downstream2");
    FlowNodeWrapper ds1Node = assertStageAndEdges(nodes, "downstream1", "Double-downstream");
    FlowNodeWrapper ds2Node = assertStageAndEdges(nodes, "downstream2", "Double-downstream");
    FlowNodeWrapper ddsNode = assertStageAndEdges(nodes, "Double-downstream");
    assertEquals("Unexpected stages in graph", 5, nodes.size());
    Collection<NodeDownstreamBuildAction> actions = ds1Node.getPipelineActions(NodeDownstreamBuildAction.class);
    assertEquals("downstream1 stage built downstream1", 1, ds1Node.getPipelineActions(NodeDownstreamBuildAction.class).stream().filter(action -> action.getLink().getHref().contains("downstream1")).count());
    assertEquals("downstream2 stage built downstream2", 1, ds2Node.getPipelineActions(NodeDownstreamBuildAction.class).stream().filter(action -> action.getLink().getHref().contains("downstream2")).count());
    assertEquals("Double-downstream stage built downstream1", 1, ddsNode.getPipelineActions(NodeDownstreamBuildAction.class).stream().filter(action -> action.getLink().getHref().contains("downstream1")).count());
    assertEquals("Double-downstream stage built downstream2", 1, ddsNode.getPipelineActions(NodeDownstreamBuildAction.class).stream().filter(action -> action.getLink().getHref().contains("downstream2")).count());
}
Also used : NodeDownstreamBuildAction(io.jenkins.blueocean.listeners.NodeDownstreamBuildAction) WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun) Test(org.junit.Test)

Example 2 with NodeDownstreamBuildAction

use of io.jenkins.blueocean.listeners.NodeDownstreamBuildAction in project blueocean-plugin by jenkinsci.

the class GraphBuilderTest method downstreamBuildLinks.

@Test
public void downstreamBuildLinks() throws Exception {
    // Any simple pipeline would do for these
    createJob("downstream1", "declarativeQueuedAgent.jenkinsfile");
    createJob("downstream2", "declarativeQueuedAgent.jenkinsfile");
    WorkflowRun run = createAndRunJob("downstreamBuildLinks", "downstreamBuildLinks.jenkinsfile");
    NodeGraphBuilder graph = NodeGraphBuilder.NodeGraphBuilderFactory.getInstance(run);
    List<FlowNodeWrapper> nodes = graph.getPipelineNodes();
    assertStageAndEdges(nodes, "Stage the first", "Stage the second");
    assertStageAndEdges(nodes, "Stage the second", "downstream1", "downstream2");
    FlowNodeWrapper ds1Node = assertStageAndEdges(nodes, "downstream1", "Double-downstream");
    FlowNodeWrapper ds2Node = assertStageAndEdges(nodes, "downstream2", "Double-downstream");
    FlowNodeWrapper ddsNode = assertStageAndEdges(nodes, "Double-downstream");
    assertEquals("Unexpected stages in graph", 5, nodes.size());
    Collection<NodeDownstreamBuildAction> actions = ds1Node.getPipelineActions(NodeDownstreamBuildAction.class);
    assertEquals("downstream1 stage built downstream1", 1, ds1Node.getPipelineActions(NodeDownstreamBuildAction.class).stream().filter(action -> action.getLink().getHref().contains("downstream1")).count());
    assertEquals("downstream2 stage built downstream2", 1, ds2Node.getPipelineActions(NodeDownstreamBuildAction.class).stream().filter(action -> action.getLink().getHref().contains("downstream2")).count());
    assertEquals("Double-downstream stage built downstream1", 1, ddsNode.getPipelineActions(NodeDownstreamBuildAction.class).stream().filter(action -> action.getLink().getHref().contains("downstream1")).count());
    assertEquals("Double-downstream stage built downstream2", 1, ddsNode.getPipelineActions(NodeDownstreamBuildAction.class).stream().filter(action -> action.getLink().getHref().contains("downstream2")).count());
}
Also used : NodeDownstreamBuildAction(io.jenkins.blueocean.listeners.NodeDownstreamBuildAction) WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun) Test(org.junit.Test)

Aggregations

NodeDownstreamBuildAction (io.jenkins.blueocean.listeners.NodeDownstreamBuildAction)2 WorkflowRun (org.jenkinsci.plugins.workflow.job.WorkflowRun)2 Test (org.junit.Test)2