use of org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject in project blueocean-plugin by jenkinsci.
the class MultiBranchTest method testMultiBranchPipelineBranchUnsecurePermissions.
@Test
public void testMultiBranchPipelineBranchUnsecurePermissions() throws IOException, ExecutionException, InterruptedException {
MockFolder folder1 = j.createFolder("folder1");
WorkflowMultiBranchProject mp = folder1.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 r = get("/organizations/jenkins/pipelines/folder1/pipelines/p/");
Map<String, Boolean> permissions = (Map<String, Boolean>) r.get("permissions");
Assert.assertTrue(permissions.get("create"));
Assert.assertTrue(permissions.get("read"));
Assert.assertTrue(permissions.get("start"));
Assert.assertTrue(permissions.get("stop"));
r = get("/organizations/jenkins/pipelines/folder1/pipelines/p/branches/master/");
permissions = (Map<String, Boolean>) r.get("permissions");
Assert.assertTrue(permissions.get("create"));
Assert.assertTrue(permissions.get("start"));
Assert.assertTrue(permissions.get("stop"));
Assert.assertTrue(permissions.get("read"));
}
use of org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject in project blueocean-plugin by jenkinsci.
the class MultiBranchTest method getMultiBranchPipelineRunChangeSets.
@Test
public void getMultiBranchPipelineRunChangeSets() throws Exception {
setupScmWithChangeSet();
WorkflowMultiBranchProject mp = j.jenkins.createProject(WorkflowMultiBranchProject.class, "p");
mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, sampleRepo3.toString(), "", "*", "", false)));
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(1, mp.getItems().size());
String[] messages = { "tweaked11", "tweaked12", "tweaked13", "tweaked14" };
sampleRepo3.git("checkout", "master");
sampleRepo3.write("file", "subsequent content11");
sampleRepo3.git("commit", "--all", "--message=" + messages[0]);
sampleRepo3.git("checkout", "master");
sampleRepo3.write("file", "subsequent content12");
sampleRepo3.git("commit", "--all", "--message=" + messages[1]);
sampleRepo3.git("checkout", "master");
sampleRepo3.write("file", "subsequent content13");
sampleRepo3.git("commit", "--all", "--message=" + messages[2]);
sampleRepo3.git("checkout", "master");
sampleRepo3.write("file", "subsequent content14");
sampleRepo3.git("commit", "--all", "--message=" + messages[3]);
WorkflowRun b4 = p.scheduleBuild2(0).get();
j.waitUntilNoActivity();
assertEquals(b4.getNumber(), 2);
Assert.assertEquals(1, b4.getChangeSets().size());
ChangeLogSet.Entry changeLog = b4.getChangeSets().get(0).iterator().next();
int i = 0;
for (ChangeLogSet.Entry c : b4.getChangeSets().get(0)) {
Assert.assertEquals(messages[i], c.getMsg());
i++;
}
Map run = get("/organizations/jenkins/pipelines/p/branches/master/runs/" + b4.getId() + "/");
validateRun(b4, run);
List<Map> changetSet = (List<Map>) run.get("changeSet");
Map c = changetSet.get(0);
Assert.assertEquals(changeLog.getCommitId(), c.get("commitId"));
Map a = (Map) c.get("author");
Assert.assertEquals(changeLog.getAuthor().getId(), a.get("id"));
Assert.assertEquals(changeLog.getAuthor().getFullName(), a.get("fullName"));
int j = 0;
for (ChangeLogSet.Entry cs : b4.getChangeSets().get(0)) {
Assert.assertEquals(cs.getCommitId(), changetSet.get(j).get("commitId"));
j++;
}
Assert.assertEquals(i, j);
}
use of org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject in project blueocean-plugin by jenkinsci.
the class MultiBranchTest method resolveMbpLink.
@Test
public void resolveMbpLink() throws Exception {
WorkflowMultiBranchProject mp = j.jenkins.createProject(WorkflowMultiBranchProject.class, "p");
FreeStyleProject f = j.jenkins.createProject(FreeStyleProject.class, "f");
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();
j.waitUntilNoActivity();
Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/p/", LinkResolver.resolveLink(mp).getHref());
Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/p/branches/master/", LinkResolver.resolveLink(mp.getBranch("master")).getHref());
Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/p/branches/feature%252Fux-1/", LinkResolver.resolveLink(mp.getBranch("feature%2Fux-1")).getHref());
Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/p/branches/feature2/", LinkResolver.resolveLink(mp.getBranch("feature2")).getHref());
Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/f/", LinkResolver.resolveLink(f).getHref());
}
use of org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject in project blueocean-plugin by jenkinsci.
the class MultiBranchTest method getPipelinesTest.
@Test
public void getPipelinesTest() 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();
List<Map> responses = get("/search/?q=type:pipeline;excludedFromFlattening:jenkins.branch.MultiBranchProject", List.class);
Assert.assertEquals(1, responses.size());
}
use of org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject in project blueocean-plugin by jenkinsci.
the class MultiBranchTest method getMultiBranchPipelines.
@Test
public void getMultiBranchPipelines() throws IOException, ExecutionException, InterruptedException {
Assume.assumeTrue(runAllTests());
WorkflowMultiBranchProject mp = j.jenkins.createProject(WorkflowMultiBranchProject.class, "p");
FreeStyleProject f = j.jenkins.createProject(FreeStyleProject.class, "f");
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();
List<Map> resp = get("/organizations/jenkins/pipelines/", List.class);
Assert.assertEquals(2, resp.size());
validatePipeline(f, resp.get(0));
validateMultiBranchPipeline(mp, resp.get(1), 3);
Assert.assertEquals(mp.getBranch("master").getBuildHealth().getScore(), resp.get(0).get("weatherScore"));
}
Aggregations