use of jenkins.branch.DefaultBranchPropertyStrategy in project blueocean-plugin by jenkinsci.
the class SseEventTest method multiBranchJobEventsWithCustomOrg.
@Test
public void multiBranchJobEventsWithCustomOrg() throws Exception {
MockFolder folder = j.createFolder("TestOrgFolderName");
assertNotNull(folder);
setupScm();
final OneShotEvent success = new OneShotEvent();
final Boolean[] pipelineNameMatched = { null };
final Boolean[] mbpPipelineNameMatched = { null };
SSEConnection con = new SSEConnection(j.getURL(), "me", new ChannelSubscriber() {
@Override
public void onMessage(@Nonnull Message message) {
System.out.println(message);
if ("job".equals(message.get(jenkins_channel))) {
if ("org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject".equals(message.get(jenkins_object_type))) {
if ("pipeline1".equals(message.get(blueocean_job_pipeline_name))) {
mbpPipelineNameMatched[0] = true;
} else {
mbpPipelineNameMatched[0] = false;
}
} else if ("org.jenkinsci.plugins.workflow.job.WorkflowJob".equals(message.get(jenkins_object_type))) {
if ("pipeline1".equals(message.get(blueocean_job_pipeline_name))) {
pipelineNameMatched[0] = true;
} else {
pipelineNameMatched[0] = false;
}
}
}
if (pipelineNameMatched[0] != null && mbpPipelineNameMatched[0] != null) {
success.signal();
}
}
});
con.subscribe("pipeline");
con.subscribe("job");
final WorkflowMultiBranchProject mp = folder.createProject(WorkflowMultiBranchProject.class, "pipeline1");
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();
WorkflowJob p = mp.getItem("master");
if (p == null) {
mp.getIndexing().writeWholeLogTo(System.out);
fail("master project not found");
}
j.waitUntilNoActivity();
WorkflowRun b1 = p.getLastBuild();
assertEquals(1, b1.getNumber());
assertEquals(2, mp.getItems().size());
success.block(5000);
con.close();
if (success.isSignaled()) {
assertTrue(pipelineNameMatched[0]);
assertTrue(mbpPipelineNameMatched[0]);
}
}
use of jenkins.branch.DefaultBranchPropertyStrategy 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 jenkins.branch.DefaultBranchPropertyStrategy in project blueocean-plugin by jenkinsci.
the class MultiBranchTest method getBranchWithEncodedPath.
@Test
public void getBranchWithEncodedPath() 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/p/branches/", List.class);
String href = null;
for (Map r : resp) {
if (r.get("name").equals("feature%2Fux-1")) {
href = (String) ((Map) ((Map) r.get("_links")).get("self")).get("href");
href = StringUtils.substringAfter(href, "/blue/rest");
}
}
Assert.assertNotNull(href);
Map r = get(href);
Assert.assertEquals("feature%2Fux-1", r.get("name"));
}
use of jenkins.branch.DefaultBranchPropertyStrategy in project blueocean-plugin by jenkinsci.
the class MultiBranchTest method multiBranchPipelineIndex.
@Test
public void multiBranchPipelineIndex() throws Exception {
User user = login();
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());
}
Map map = new RequestBuilder(baseUrl).post("/organizations/jenkins/pipelines/p/runs/").jwtToken(getJwtToken(j.jenkins, user.getId(), user.getId())).crumb(getCrumb(j.jenkins)).data(Collections.emptyMap()).status(200).build(Map.class);
assertNotNull(map);
}
use of jenkins.branch.DefaultBranchPropertyStrategy 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());
}
Aggregations