Search in sources :

Example 21 with FlowNode

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

the class PipelineNodeTest method getPipelineStepsTest.

@Test
public void getPipelineStepsTest() throws Exception {
    WorkflowJob job1 = j.jenkins.createProject(WorkflowJob.class, "pipeline1");
    job1.setDefinition(new CpsFlowDefinition("stage 'build'\n" + "node{\n" + "  sh \"echo Building...\"\n" + "}\n" + "\n" + "stage 'test'\n" + "parallel 'unit':{\n" + "  node{\n" + "    echo \"Unit testing...\"\n" + "    sh \"echo Tests running\"\n" + "    sh \"echo Tests completed\"\n" + "  }\n" + "},'integration':{\n" + "  node{\n" + "    echo \"Integration testing...\"\n" + "  }\n" + "}, 'ui':{\n" + "  node{\n" + "    echo \"UI testing...\"\n" + "  }\n" + "}\n" + "\n" + "node{\n" + "  echo \"Done Testing\"\n" + "}" + "\n" + "stage 'deploy'\n" + "node{\n" + "  echo \"Deploying\"\n" + "}" + "\n" + "stage 'deployToProd'\n" + "node{\n" + "  echo \"Deploying to production\"\n" + "}"));
    WorkflowRun b1 = job1.scheduleBuild2(0).get();
    j.assertBuildStatusSuccess(b1);
    FlowGraphTable nodeGraphTable = new FlowGraphTable(b1.getExecution());
    nodeGraphTable.build();
    List<FlowNode> nodes = getStages(nodeGraphTable);
    List<FlowNode> parallelNodes = getParallelNodes(nodeGraphTable);
    Assert.assertEquals(7, nodes.size());
    Assert.assertEquals(3, parallelNodes.size());
    List<Map> resp = get("/organizations/jenkins/pipelines/pipeline1/runs/1/nodes/" + nodes.get(1).getId() + "/steps/", List.class);
    Assert.assertEquals(6, resp.size());
    Map step = get("/organizations/jenkins/pipelines/pipeline1/runs/1/nodes/" + parallelNodes.get(0).getId() + "/steps/" + resp.get(0).get("id"), Map.class);
    assertNotNull(step);
    String stepLog = get("/organizations/jenkins/pipelines/pipeline1/runs/1/nodes/" + parallelNodes.get(0).getId() + "/steps/" + resp.get(0).get("id") + "/log", String.class);
    assertNotNull(stepLog);
}
Also used : CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) FlowGraphTable(org.jenkinsci.plugins.workflow.support.visualization.table.FlowGraphTable) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun) FlowNode(org.jenkinsci.plugins.workflow.graph.FlowNode) Test(org.junit.Test)

Example 22 with FlowNode

use of org.jenkinsci.plugins.workflow.graph.FlowNode 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)

Aggregations

FlowNode (org.jenkinsci.plugins.workflow.graph.FlowNode)22 WorkflowRun (org.jenkinsci.plugins.workflow.job.WorkflowRun)14 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)13 Test (org.junit.Test)13 ImmutableMap (com.google.common.collect.ImmutableMap)12 Map (java.util.Map)12 CpsFlowDefinition (org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition)11 ImmutableList (com.google.common.collect.ImmutableList)9 RunList (hudson.util.RunList)9 List (java.util.List)9 StepAtomNode (org.jenkinsci.plugins.workflow.cps.nodes.StepAtomNode)4 TimingInfo (org.jenkinsci.plugins.workflow.pipelinegraphanalysis.TimingInfo)4 FlowGraphTable (org.jenkinsci.plugins.workflow.support.visualization.table.FlowGraphTable)4 BlueRun (io.jenkins.blueocean.rest.model.BlueRun)3 BluePipelineStep (io.jenkins.blueocean.rest.model.BluePipelineStep)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 BranchSource (jenkins.branch.BranchSource)2 GitSCMSource (jenkins.plugins.git.GitSCMSource)2 SCMSource (jenkins.scm.api.SCMSource)2