use of org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject 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 org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject in project blueocean-plugin by jenkinsci.
the class MultiBranchTest method getMultiBranchPipelinesWithNonMasterBranch.
@Test
public void getMultiBranchPipelinesWithNonMasterBranch() throws Exception {
sampleRepo.git("branch", "-D", "master");
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();
List<Map> resp = get("/organizations/jenkins/pipelines/", List.class);
Assert.assertEquals(1, resp.size());
validateMultiBranchPipeline(mp, resp.get(0), 2);
assertNull(mp.getBranch("master"));
}
use of org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject in project blueocean-plugin by jenkinsci.
the class PipelineNodeTest method declarativeSyntheticSteps.
@Test
public void declarativeSyntheticSteps() 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(\"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(2, stages.size());
Assert.assertEquals("build", stages.get(0).getDisplayName());
Assert.assertEquals("deploy", stages.get(1).getDisplayName());
List<Map> resp = get("/organizations/jenkins/pipelines/p/pipelines/master/runs/" + b1.getId() + "/nodes/", List.class);
Assert.assertEquals(2, resp.size());
Assert.assertEquals("build", resp.get(0).get("displayName"));
Assert.assertEquals("deploy", resp.get(1).get("displayName"));
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(4, resp.size());
}
use of org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject in project blueocean-plugin by jenkinsci.
the class BlueMessageEnricher method enrich.
@Override
public void enrich(@Nonnull Message message) {
// TODO: Get organization name in generic way once multi-organization support is implemented in API
message.set(EventProps.Jenkins.jenkins_org, OrganizationImpl.INSTANCE.getName());
String channelName = message.getChannelName();
if (channelName.equals(Events.JobChannel.NAME)) {
JobChannelMessage jobChannelMessage = (JobChannelMessage) message;
Item jobChannelItem = jobChannelMessage.getJobChannelItem();
Link jobUrl = LinkResolver.resolveLink(jobChannelItem);
jobChannelMessage.set(BlueEventProps.blueocean_job_rest_url, jobUrl.getHref());
jobChannelMessage.set(BlueEventProps.blueocean_job_pipeline_name, jobChannelItem.getFullName());
if (jobChannelItem instanceof WorkflowJob) {
ItemGroup<? extends Item> parent = jobChannelItem.getParent();
if (parent instanceof WorkflowMultiBranchProject) {
String multiBranchProjectName = parent.getFullName();
jobChannelMessage.set(BlueEventProps.blueocean_job_pipeline_name, multiBranchProjectName);
jobChannelMessage.set(BlueEventProps.blueocean_job_branch_name, jobChannelItem.getName());
}
}
}
}
use of org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject in project blueocean-plugin by jenkinsci.
the class BlueOceanWebURLBuilderTest method getMultiBranchPipelineInsideFolder.
@Test
public void getMultiBranchPipelineInsideFolder() throws Exception {
MockFolder folder1 = jenkinsRule.createFolder("folder1");
MockFolder folder2 = folder1.createProject(MockFolder.class, "folder two with spaces");
WorkflowMultiBranchProject mp = folder2.createProject(WorkflowMultiBranchProject.class, "p");
String blueOceanURL;
blueOceanURL = BlueOceanWebURLBuilder.toBlueOceanURL(mp);
assertURL("blue/organizations/jenkins/folder1%2Ffolder%20two%20with%20spaces%2Fp/branches", blueOceanURL);
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();
jenkinsRule.waitUntilNoActivity();
// All branch jobs should just resolve back to the same top level branches
// page for the multibranch job in Blue Ocean.
WorkflowJob masterJob = findBranchProject(mp, "master");
blueOceanURL = BlueOceanWebURLBuilder.toBlueOceanURL(masterJob);
assertURL("blue/organizations/jenkins/folder1%2Ffolder%20two%20with%20spaces%2Fp/branches", blueOceanURL);
WorkflowJob featureUx1Job = findBranchProject(mp, "feature/ux-1");
blueOceanURL = BlueOceanWebURLBuilder.toBlueOceanURL(featureUx1Job);
assertURL("blue/organizations/jenkins/folder1%2Ffolder%20two%20with%20spaces%2Fp/branches", blueOceanURL);
WorkflowJob feature2Job = findBranchProject(mp, "feature2");
blueOceanURL = BlueOceanWebURLBuilder.toBlueOceanURL(feature2Job);
assertURL("blue/organizations/jenkins/folder1%2Ffolder%20two%20with%20spaces%2Fp/branches", blueOceanURL);
// Runs on the jobs
blueOceanURL = BlueOceanWebURLBuilder.toBlueOceanURL(masterJob.getFirstBuild());
assertURL("blue/organizations/jenkins/folder1%2Ffolder%20two%20with%20spaces%2Fp/detail/master/1", blueOceanURL);
blueOceanURL = BlueOceanWebURLBuilder.toBlueOceanURL(featureUx1Job.getFirstBuild());
assertURL("blue/organizations/jenkins/folder1%2Ffolder%20two%20with%20spaces%2Fp/detail/feature%2Fux-1/1", blueOceanURL);
}
Aggregations