use of hudson.model.Job in project hudson-2.x by hudson.
the class CopyJobCommand method run.
protected int run() throws Exception {
Hudson h = Hudson.getInstance();
h.checkPermission(Item.CREATE);
if (h.getItem(dst) != null) {
stderr.println("Job '" + dst + "' already exists");
return -1;
}
h.copy(src, dst);
Job newJob = (Job) Hudson.getInstance().getItem(dst);
if (forceSave && null != newJob) {
newJob.save();
}
return 0;
}
use of hudson.model.Job in project blueocean-plugin by jenkinsci.
the class BranchContainerImpl method iterator.
@Override
@SuppressWarnings("unchecked")
public Iterator<BluePipeline> iterator() {
List<BluePipeline> branches = new ArrayList<>();
Collection<Job> jobs = pipeline.mbp.getAllJobs();
jobs = ContainerFilter.filter(jobs);
for (Job j : jobs) {
branches.add(new BranchImpl(j, getLink()));
}
return Ordering.from(BRANCH_COMPARITOR).sortedCopy(branches).iterator();
}
use of hudson.model.Job in project blueocean-plugin by jenkinsci.
the class MultiBranchPipelineImpl method favorite.
@Override
public BlueFavorite favorite(@JsonBody BlueFavoriteAction favoriteAction) {
if (favoriteAction == null) {
throw new ServiceException.BadRequestExpception("Must provide pipeline name");
}
Job job = PrimaryBranch.resolve(mbp);
if (job == null) {
throw new ServiceException.BadRequestExpception("no default branch to favorite");
}
FavoriteUtil.toggle(favoriteAction, job);
return new FavoriteImpl(new BranchImpl(job, getLink().rel("branches")), getLink().rel("favorite"));
}
use of hudson.model.Job in project blueocean-plugin by jenkinsci.
the class MultiBranchTest method testBranchInfo.
@Test
public void testBranchInfo() {
Job job = mock(Job.class);
BranchImpl branch = new BranchImpl(job, new Link("foo"));
assertNotNull(branch.getBranch());
assertNull(branch.getBranch().getUrl());
assertFalse(branch.getBranch().isPrimary());
ObjectMetadataAction oma = new ObjectMetadataAction("My Branch", "A feature branch", "https://path/to/branch");
when(job.getAction(ObjectMetadataAction.class)).thenReturn(oma);
assertEquals("https://path/to/branch", branch.getBranch().getUrl());
assertFalse(branch.getBranch().isPrimary());
when(job.getAction(PrimaryInstanceMetadataAction.class)).thenReturn(new PrimaryInstanceMetadataAction());
assertTrue(branch.getBranch().isPrimary());
}
use of hudson.model.Job in project blueocean-plugin by jenkinsci.
the class MultiBranchTest method testGetURL.
@Test
public void testGetURL() {
Job job = mock(Job.class);
BranchImpl branch = new BranchImpl(job, new Link("foo"));
assertNotNull(branch.getBranch());
assertNull(branch.getBranch().getUrl());
assertFalse(branch.getBranch().isPrimary());
ObjectMetadataAction oma = new ObjectMetadataAction("My Branch", "A feature branch", "https://path/to/branch");
when(job.getAction(ObjectMetadataAction.class)).thenReturn(oma);
assertEquals("https://path/to/branch", branch.getBranch().getUrl());
}
Aggregations