use of jenkins.branch.DefaultBranchPropertyStrategy in project blueocean-plugin by jenkinsci.
the class MultiBranchTest method getMultiBranchPipelineRuns.
@Test
public void getMultiBranchPipelineRuns() 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());
//execute feature/ux-1 branch build
p = scheduleAndFindBranchProject(mp, "feature%2Fux-1");
j.waitUntilNoActivity();
WorkflowRun b2 = p.getLastBuild();
assertEquals(1, b2.getNumber());
//execute feature 2 branch build
p = scheduleAndFindBranchProject(mp, "feature2");
j.waitUntilNoActivity();
WorkflowRun b3 = p.getLastBuild();
assertEquals(1, b3.getNumber());
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"));
}
Assert.assertTrue(branchNames.contains(((Map) (br.get(0).get("latestRun"))).get("pipeline")));
for (String n : branches) {
assertTrue(branchNames.contains(n));
}
WorkflowRun[] runs = { b1, b2, b3 };
int i = 0;
for (String n : branches) {
WorkflowRun b = runs[i];
j.waitForCompletion(b);
Map run = get("/organizations/jenkins/pipelines/p/branches/" + Util.rawEncode(n) + "/runs/" + b.getId());
validateRun(b, run);
i++;
}
Map pr = get("/organizations/jenkins/pipelines/p/");
validateMultiBranchPipeline(mp, pr, 3, 3, 0);
sampleRepo.git("checkout", "master");
sampleRepo.write("file", "subsequent content11");
sampleRepo.git("commit", "--all", "--message=tweaked11");
p = scheduleAndFindBranchProject(mp, "master");
j.waitUntilNoActivity();
WorkflowRun b4 = p.getLastBuild();
assertEquals(2, b4.getNumber());
List<Map> run = get("/organizations/jenkins/pipelines/p/branches/master/runs/", List.class);
validateRun(b4, run.get(0));
}
use of jenkins.branch.DefaultBranchPropertyStrategy 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);
}
}
use of jenkins.branch.DefaultBranchPropertyStrategy in project blueocean-plugin by jenkinsci.
the class MultiBranchTest method startMultiBranchPipelineRuns.
@Test
public void startMultiBranchPipelineRuns() 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, "feature%2Fux-1");
j.waitUntilNoActivity();
Map resp = post("/organizations/jenkins/pipelines/p/branches/" + Util.rawEncode("feature%2Fux-1") + "/runs/", Collections.EMPTY_MAP);
String id = (String) resp.get("id");
String link = getHrefFromLinks(resp, "self");
Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/p/branches/feature%252Fux-1/queue/" + id + "/", link);
}
use of jenkins.branch.DefaultBranchPropertyStrategy in project blueocean-plugin by jenkinsci.
the class MultiBranchTest method getPipelineJobActivitiesNoBranches.
@Test
public void getPipelineJobActivitiesNoBranches() 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/activities").build(List.class);
Assert.assertEquals(0, l.size());
List branches = request().get("/organizations/jenkins/pipelines/p/branches").build(List.class);
Assert.assertEquals(0, branches.size());
}
use of jenkins.branch.DefaultBranchPropertyStrategy 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();
Map response = get("/organizations/jenkins/pipelines/p/branches/master/", Map.class);
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(JENKINS_JOB) && classes.contains(JENKINS_WORKFLOW_JOB) && classes.contains(BLUE_BRANCH) && classes.contains(BLUE_PIPELINE) && classes.contains(PULL_REQUEST));
}
Aggregations