use of jenkins.branch.BranchSource in project blueocean-plugin by jenkinsci.
the class RunImplTest method replayRunTestMB.
// Disabled, see JENKINS-40084
@Test
@Ignore
public void replayRunTestMB() throws Exception {
j.createOnlineSlave(Label.get("remote"));
sampleRepo.write("Jenkinsfile", "node('remote') {\n" + " ws {\n" + " checkout scm\n" + " stage 'build'\n " + "node {echo 'Building'}\n" + " stage 'test'\nnode { echo 'Testing'}\n" + " stage 'deploy'\nnode { echo 'Deploying'}\n" + " }\n" + " }");
sampleRepo.git("add", "Jenkinsfile");
sampleRepo.git("commit", "--message=init");
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();
WorkflowJob job1 = mp.getItem("master");
WorkflowRun b1 = job1.scheduleBuild2(0).waitForStart();
j.waitForCompletion(b1);
j.assertBuildStatusSuccess(b1);
sampleRepo.write("file1", "");
sampleRepo.git("add", "file1");
sampleRepo.git("commit", "--message=init");
WorkflowRun b2 = job1.scheduleBuild2(0).get();
j.assertBuildStatusSuccess(b2);
Assert.assertNotEquals(new PipelineRunImpl(b1, null, null).getCommitId(), new PipelineRunImpl(b2, null, null).getCommitId());
Map replayBuild = request().post("/organizations/jenkins/pipelines/p/branches/master/runs/" + b1.getNumber() + "/replay").build(Map.class);
Queue.Item item = j.getInstance().getQueue().getItem(Long.parseLong((String) replayBuild.get("id")));
WorkflowRun replayedRun = (WorkflowRun) item.getFuture().get();
Map r = request().get("/organizations/jenkins/pipelines/p/branches/master/runs/" + replayedRun.getNumber() + "/").build(Map.class);
assertEquals(new PipelineRunImpl(b1, null, null).getCommitId(), r.get("commitId"));
}
use of jenkins.branch.BranchSource 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 jenkins.branch.BranchSource in project blueocean-plugin by jenkinsci.
the class JobAnalyticsTest method createMultiBranch.
private void createMultiBranch(GitSampleRepoRule rule) throws Exception {
WorkflowMultiBranchProject mp = j.createProject(WorkflowMultiBranchProject.class, UUID.randomUUID().toString());
mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, rule.toString(), "", "*", "", false), new DefaultBranchPropertyStrategy(new BranchProperty[0])));
mp.save();
mp.scheduleBuild2(0).getFuture().get();
mp.getIndexing().getLogText().writeLogTo(0, System.out);
j.waitUntilNoActivity();
WorkflowJob master = mp.getItemByBranchName("master");
assertNotNull(master);
WorkflowRun lastBuild = master.getLastBuild();
assertNotNull(lastBuild);
assertEquals(Result.SUCCESS, lastBuild.getResult());
}
use of jenkins.branch.BranchSource in project blueocean-plugin by jenkinsci.
the class AbstractMultiBranchCreateRequest method create.
@Override
@SuppressWarnings("unchecked")
public BluePipeline create(@Nonnull BlueOrganization organization, @Nonnull Reachable parent) throws IOException {
validateInternal(getName(), scmConfig, organization);
MultiBranchProject project = createMultiBranchProject(organization);
assignCredentialToProject(scmConfig, project);
SCMSource source = createSource(project, scmConfig).withId("blueocean");
project.setSourcesList(Collections.singletonList(new BranchSource(source)));
source.afterSave();
project.save();
final boolean hasJenkinsfile = repoHasJenkinsFile(source);
if (!hasJenkinsfile) {
sendMultibranchIndexingCompleteEvent(project, 5);
AbstractScmSourceEvent scmSourceEvent = getScmSourceEvent(project, source);
if (scmSourceEvent != null) {
SCMSourceEvent.fireNow(scmSourceEvent);
}
} else {
project.scheduleBuild(new Cause.UserIdCause());
}
return BluePipelineFactory.getPipelineInstance(project, OrganizationFactory.getInstance().getContainingOrg(project.getItemGroup()));
}
use of jenkins.branch.BranchSource 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());
}
Aggregations