use of org.jenkinsci.plugins.workflow.job.WorkflowJob in project blueocean-plugin by jenkinsci.
the class JobAnalyticsTest method createMultiBranch.
private void createMultiBranch(GitSampleRepoRule rule) throws Exception {
WorkflowMultiBranchProject mp = j.createProject(WorkflowMultiBranchProject.class, UUID.randomUUID().toString());
mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, rule.toString(), "", "*", "", false), new DefaultBranchPropertyStrategy(new BranchProperty[0])));
mp.save();
mp.scheduleBuild2(0).getFuture().get();
mp.getIndexing().getLogText().writeLogTo(0, System.out);
j.waitUntilNoActivity();
WorkflowJob master = mp.getItemByBranchName("master");
assertNotNull(master);
WorkflowRun lastBuild = master.getLastBuild();
assertNotNull(lastBuild);
assertEquals(Result.SUCCESS, lastBuild.getResult());
}
use of org.jenkinsci.plugins.workflow.job.WorkflowJob in project blueocean-plugin by jenkinsci.
the class BlueJUnitTestResultTest method createsTestResult.
@Test
public void createsTestResult() throws Exception {
URL resource = Resources.getResource(getClass(), "BlueJUnitTestResultTest.jenkinsfile");
String jenkinsFile = Resources.toString(resource, Charsets.UTF_8);
WorkflowJob p = j.createProject(WorkflowJob.class, "project");
p.setDefinition(new CpsFlowDefinition(jenkinsFile, false));
p.save();
Run r = p.scheduleBuild2(0).waitForStart();
j.waitUntilNoActivity();
BlueRun test = BlueRunFactory.getRun(r, new Reachable() {
@Override
public Link getLink() {
return new Link("test");
}
});
Assert.assertEquals(3, Iterators.size(test.getTests().iterator()));
BluePipelineNode node = mock(BluePipelineNode.class);
when(node.getId()).thenReturn("6");
}
use of org.jenkinsci.plugins.workflow.job.WorkflowJob in project blueocean-plugin by jenkinsci.
the class BlueTrendsApiTest method getJUnitTrends.
@Test
public void getJUnitTrends() throws Exception {
URL resource = Resources.getResource(getClass(), "BlueJUnitTestResultTest.jenkinsfile");
String jenkinsFile = Resources.toString(resource, Charsets.UTF_8);
WorkflowJob p = j.createProject(WorkflowJob.class, "project");
p.setDefinition(new CpsFlowDefinition(jenkinsFile, false));
p.save();
Run run;
for (int i = 0; i < 10; i++) {
run = p.scheduleBuild2(0).waitForStart();
j.waitForCompletion(run);
}
Map trend = new RequestBuilder(baseUrl).get("/organizations/jenkins/pipelines/" + p.getName() + "/trends/junit/").build(Map.class);
List rows;
Map testRow;
Assert.assertNotNull(trend);
Map columns = (Map) trend.get("columns");
Assert.assertNotNull(columns);
Assert.assertEquals(7, columns.keySet().size());
rows = new RequestBuilder(baseUrl).get("/organizations/jenkins/pipelines/" + p.getName() + "/trends/junit/rows").build(List.class);
Assert.assertNotNull(rows);
Assert.assertEquals(10, rows.size());
testRow = (Map) rows.get(0);
Assert.assertEquals("10", testRow.get(BlueTableRow.ID));
Assert.assertEquals(3, testRow.get(BlueJUnitTrend.TOTAL));
Assert.assertEquals(2, testRow.get(BlueJUnitTrend.PASSED));
Assert.assertEquals(1, testRow.get(BlueJUnitTrend.FAILED));
Assert.assertEquals(1, testRow.get(BlueJUnitTrend.EXISTING_FAILED));
Assert.assertEquals(0, testRow.get(BlueJUnitTrend.FIXED));
Assert.assertEquals(0, testRow.get(BlueJUnitTrend.REGRESSIONS));
Assert.assertEquals(0, testRow.get(BlueJUnitTrend.SKIPPED));
rows = new RequestBuilder(baseUrl).get("/organizations/jenkins/pipelines/" + p.getName() + "/trends/junit/rows?start=5&limit=5").build(List.class);
Assert.assertNotNull(rows);
Assert.assertEquals(5, rows.size());
testRow = (Map) rows.get(0);
Assert.assertEquals("5", testRow.get(BlueTableRow.ID));
}
use of org.jenkinsci.plugins.workflow.job.WorkflowJob in project blueocean-plugin by jenkinsci.
the class MultiBranchTest method getMultiBranchPipelineRunStages.
@Test
public void getMultiBranchPipelineRunStages() throws Exception {
WorkflowMultiBranchProject mp = j.jenkins.createProject(WorkflowMultiBranchProject.class, "p");
mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", false), new DefaultBranchPropertyStrategy(new BranchProperty[0])));
for (SCMSource source : mp.getSCMSources()) {
assertEquals(mp, source.getOwner());
}
WorkflowJob p = scheduleAndFindBranchProject(mp, "master");
j.waitUntilNoActivity();
WorkflowRun b1 = p.getLastBuild();
assertEquals(1, b1.getNumber());
assertEquals(3, mp.getItems().size());
j.waitForCompletion(b1);
List<Map> nodes = get("/organizations/jenkins/pipelines/p/branches/master/runs/1/nodes", List.class);
Assert.assertEquals(3, nodes.size());
}
use of org.jenkinsci.plugins.workflow.job.WorkflowJob in project blueocean-plugin by jenkinsci.
the class PipelineNodeTest method BlockStageNodesFailureTest1.
@Test
public void BlockStageNodesFailureTest1() throws Exception {
WorkflowJob job1 = j.jenkins.createProject(WorkflowJob.class, "pipeline1");
job1.setDefinition(new CpsFlowDefinition("node{\n" + " stage ('Build') {\n" + " sh 'echo1 \"Building\"'\n" + " }\n" + " stage ('Test') {\n" + " sh 'echo testing'\n" + " }\n" + " stage ('Deploy') {\n" + " sh 'echo deploy'\n" + " }\n" + "}"));
WorkflowRun b1 = job1.scheduleBuild2(0).get();
j.assertBuildStatus(Result.FAILURE, b1);
List<Map> nodes = get("/organizations/jenkins/pipelines/pipeline1/runs/1/nodes/", List.class);
Assert.assertEquals(1, nodes.size());
Assert.assertEquals("FAILURE", nodes.get(0).get("result"));
Assert.assertEquals("FINISHED", nodes.get(0).get("state"));
}
Aggregations