use of jenkins.branch.BranchSource in project blueocean-plugin by jenkinsci.
the class MultiBranchTest method getMultiBranchPipelineInsideFolder.
@Test
public void getMultiBranchPipelineInsideFolder() throws IOException, ExecutionException, InterruptedException {
MockFolder folder1 = j.createFolder("folder1");
WorkflowMultiBranchProject mp = folder1.createProject(WorkflowMultiBranchProject.class, "p");
mp.setDisplayName("My MBP");
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());
}
mp.scheduleBuild2(0).getFuture().get();
Map r = get("/organizations/jenkins/pipelines/folder1/pipelines/p/");
validateMultiBranchPipeline(mp, r, 3);
Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/folder1/pipelines/p/", ((Map) ((Map) r.get("_links")).get("self")).get("href"));
Assert.assertEquals("folder1/My%20MBP", r.get("fullDisplayName"));
r = get("/organizations/jenkins/pipelines/folder1/pipelines/p/master/");
Assert.assertEquals("folder1/My%20MBP/master", r.get("fullDisplayName"));
}
use of jenkins.branch.BranchSource in project blueocean-plugin by jenkinsci.
the class MultiBranchTest method getMultiBranchPipelineActivityRuns.
@Test
public void getMultiBranchPipelineActivityRuns() 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());
}
scheduleAndFindBranchProject(mp);
j.waitUntilNoActivity();
WorkflowJob p = findBranchProject(mp, "master");
WorkflowRun b1 = p.getLastBuild();
assertEquals(1, b1.getNumber());
assertEquals(3, mp.getItems().size());
// execute feature/ux-1 branch build
p = findBranchProject(mp, "feature%2Fux-1");
WorkflowRun b2 = p.getLastBuild();
assertEquals(1, b2.getNumber());
// execute feature 2 branch build
p = findBranchProject(mp, "feature2");
WorkflowRun b3 = p.getLastBuild();
assertEquals(1, b3.getNumber());
List<Map> resp = get("/organizations/jenkins/pipelines/p/runs", List.class);
Assert.assertEquals(3, resp.size());
Date d1 = new SimpleDateFormat(DATE_FORMAT_STRING).parse((String) resp.get(0).get("startTime"));
Date d2 = new SimpleDateFormat(DATE_FORMAT_STRING).parse((String) resp.get(1).get("startTime"));
Date d3 = new SimpleDateFormat(DATE_FORMAT_STRING).parse((String) resp.get(2).get("startTime"));
Assert.assertTrue(d1.compareTo(d2) >= 0);
Assert.assertTrue(d2.compareTo(d3) >= 0);
for (Map m : resp) {
BuildData d;
WorkflowRun r;
if (m.get("pipeline").equals("master")) {
r = b1;
d = b1.getAction(BuildData.class);
} else if (m.get("pipeline").equals("feature2")) {
r = b3;
d = b3.getAction(BuildData.class);
} else {
r = b2;
d = b2.getAction(BuildData.class);
}
validateRun(r, m);
String commitId = "";
if (d != null) {
commitId = d.getLastBuiltRevision().getSha1String();
Assert.assertEquals(commitId, m.get("commitId"));
}
}
}
use of jenkins.branch.BranchSource in project blueocean-plugin by jenkinsci.
the class MultiBranchTest method branchCapabilityTest.
@Test
public void branchCapabilityTest() 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();
// check MBP capabilities
Map<String, Object> response = get("/organizations/jenkins/pipelines/p/");
String clazz = (String) response.get("_class");
response = get("/classes/" + clazz + "/");
Assert.assertNotNull(response);
List<String> classes = (List<String>) response.get("classes");
Assert.assertTrue(classes.contains(BLUE_SCM) && classes.contains(JENKINS_MULTI_BRANCH_PROJECT) && classes.contains(BLUE_MULTI_BRANCH_PIPELINE) && classes.contains(BLUE_PIPELINE_FOLDER) && classes.contains(JENKINS_ABSTRACT_FOLDER) && classes.contains(BLUE_PIPELINE));
response = get("/organizations/jenkins/pipelines/p/branches/master/", Map.class);
clazz = (String) response.get("_class");
response = get("/classes/" + clazz + "/");
Assert.assertNotNull(response);
classes = (List<String>) response.get("classes");
Assert.assertTrue(classes.contains(JENKINS_JOB) && classes.contains(JENKINS_WORKFLOW_JOB) && classes.contains(BLUE_BRANCH) && classes.contains(BLUE_PIPELINE) && classes.contains(PULL_REQUEST));
}
use of jenkins.branch.BranchSource in project blueocean-plugin by jenkinsci.
the class MultiBranchTest method getPipelineJobRunsNoBranches.
@Test
public void getPipelineJobRunsNoBranches() throws Exception {
WorkflowMultiBranchProject mp = j.jenkins.createProject(WorkflowMultiBranchProject.class, "p");
mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, sampleRepo1.toString(), "", "*", "", false), new DefaultBranchPropertyStrategy(new BranchProperty[0])));
List l = request().get("/organizations/jenkins/pipelines/p/runs").build(List.class);
Assert.assertEquals(0, l.size());
List branches = request().get("/organizations/jenkins/pipelines/p/runs").build(List.class);
Assert.assertEquals(0, branches.size());
}
use of jenkins.branch.BranchSource in project blueocean-plugin by jenkinsci.
the class MultiBranchTest method getMultiBranchPipeline.
@Test
public void getMultiBranchPipeline() throws IOException, ExecutionException, InterruptedException {
Assume.assumeTrue(runAllTests());
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());
}
mp.scheduleBuild2(0).getFuture().get();
Map resp = get("/organizations/jenkins/pipelines/p/");
validateMultiBranchPipeline(mp, resp, 3);
List<String> names = (List<String>) resp.get("branchNames");
IsArrayContainingInAnyOrder.arrayContainingInAnyOrder(names, branches);
List<Map> br = get("/organizations/jenkins/pipelines/p/branches", List.class);
List<String> branchNames = new ArrayList<>();
List<Integer> weather = new ArrayList<>();
for (Map b : br) {
branchNames.add((String) b.get("name"));
weather.add((int) b.get("weatherScore"));
}
for (String n : branches) {
assertTrue(branchNames.contains(n));
}
for (int s : weather) {
assertEquals(100, s);
}
}
Aggregations