use of org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject 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/runs/" + id + "/", link);
}
use of org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject in project blueocean-plugin by jenkinsci.
the class PipelineNodeTest method declarativeSyntheticSkippedStage.
@Test
public void declarativeSyntheticSkippedStage() throws Exception {
setupScm("pipeline {\n" + " agent any\n" + " stages {\n" + " stage(\"build\") {\n" + " steps{\n" + " sh 'echo \"Start Build\"'\n" + " echo 'End Build'\n" + " }\n" + " }\n" + " stage(\"SkippedStage\") {\n" + " when {\n" + " expression {\n" + " return false\n" + " }\n" + " }\n" + " steps {\n" + " script {\n" + " echo \"World\"\n" + " echo \"Heal it\"\n" + " }\n" + "\n" + " }\n" + " }\n" + " stage(\"deploy\") {\n" + " steps{\n" + " sh 'echo \"Start Deploy\"'\n" + " sh 'echo \"Deploying...\"'\n" + " sh 'echo \"End Deploy\"'\n" + " } \n" + " }\n" + " }\n" + " post {\n" + " failure {\n" + " echo \"failed\"\n" + " }\n" + " success {\n" + " echo \"success\"\n" + " }\n" + " }\n" + "}");
WorkflowMultiBranchProject mp = j.jenkins.createProject(WorkflowMultiBranchProject.class, "p");
mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", false)));
for (SCMSource source : mp.getSCMSources()) {
assertEquals(mp, source.getOwner());
}
mp.scheduleBuild2(0).getFuture().get();
j.waitUntilNoActivity();
WorkflowJob p = scheduleAndFindBranchProject(mp, "master");
j.waitUntilNoActivity();
WorkflowRun b1 = p.getLastBuild();
Assert.assertEquals(Result.SUCCESS, b1.getResult());
List<FlowNode> stages = getStages(NodeGraphBuilder.NodeGraphBuilderFactory.getInstance(b1));
Assert.assertEquals(3, stages.size());
Assert.assertEquals("build", stages.get(0).getDisplayName());
Assert.assertEquals("SkippedStage", stages.get(1).getDisplayName());
Assert.assertEquals("deploy", stages.get(2).getDisplayName());
List<Map> resp = get("/organizations/jenkins/pipelines/p/pipelines/master/runs/" + b1.getId() + "/nodes/", List.class);
Assert.assertEquals(3, resp.size());
Assert.assertEquals("build", resp.get(0).get("displayName"));
Assert.assertEquals("SkippedStage", resp.get(1).get("displayName"));
Assert.assertEquals("deploy", resp.get(2).get("displayName"));
// check status
Assert.assertEquals("SUCCESS", resp.get(0).get("result"));
Assert.assertEquals("FINISHED", resp.get(0).get("state"));
Assert.assertEquals("NOT_BUILT", resp.get(1).get("result"));
Assert.assertEquals("SKIPPED", resp.get(1).get("state"));
Assert.assertEquals("SUCCESS", resp.get(2).get("result"));
Assert.assertEquals("FINISHED", resp.get(2).get("state"));
resp = get("/organizations/jenkins/pipelines/p/pipelines/master/runs/" + b1.getId() + "/steps/", List.class);
Assert.assertEquals(7, resp.size());
resp = get("/organizations/jenkins/pipelines/p/pipelines/master/runs/" + b1.getId() + "/nodes/" + stages.get(0).getId() + "/steps/", List.class);
Assert.assertEquals(3, resp.size());
resp = get("/organizations/jenkins/pipelines/p/pipelines/master/runs/" + b1.getId() + "/nodes/" + stages.get(1).getId() + "/steps/", List.class);
Assert.assertEquals(0, resp.size());
resp = get("/organizations/jenkins/pipelines/p/pipelines/master/runs/" + b1.getId() + "/nodes/" + stages.get(2).getId() + "/steps/", List.class);
Assert.assertEquals(4, resp.size());
}
use of org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject in project blueocean-plugin by jenkinsci.
the class PipelineScmTest method authorizedUserContentUpdateShouldSucceed.
@Test
public void authorizedUserContentUpdateShouldSucceed() throws IOException, ExecutionException, InterruptedException, UnirestException {
WorkflowMultiBranchProject mp = j.createProject(WorkflowMultiBranchProject.class, "mbp");
mp.setDisplayName("My MBP");
Map content = new RequestBuilder(baseUrl).status(200).jwtToken(getJwtToken(j.jenkins, bob.getId(), bob.getId())).data(ImmutableMap.of("content", ImmutableMap.of("data", "Hello World Again!"))).put("/organizations/jenkins/pipelines/mbp/scm/content").build(Map.class);
assertNotNull(content);
assertEquals("Hello World Again!", ((Map) content.get("content")).get("data"));
}
use of org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject in project blueocean-plugin by jenkinsci.
the class PipelineScmTest method AuthorizedUserContentAccessShouldSucceed.
@Test
public void AuthorizedUserContentAccessShouldSucceed() throws IOException, ExecutionException, InterruptedException, UnirestException {
WorkflowMultiBranchProject mp = j.createProject(WorkflowMultiBranchProject.class, "mbp");
mp.setDisplayName("My MBP");
Map content = new RequestBuilder(baseUrl).status(200).jwtToken(getJwtToken(j.jenkins, bob.getId(), bob.getId())).get("/organizations/jenkins/pipelines/mbp/scm/content").build(Map.class);
assertNotNull(content);
assertEquals("Hello World!", ((Map) content.get("content")).get("data"));
}
Aggregations