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);
}
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;
}
Aggregations