use of jenkins.scm.api.metadata.PrimaryInstanceMetadataAction 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 jenkins.scm.api.metadata.PrimaryInstanceMetadataAction in project gitlab-branch-source-plugin by Argelbargel.
the class SourceActions method retrieve.
@Nonnull
private List<Action> retrieve(@Nonnull GitLabSCMHead head, @CheckForNull SCMHeadEvent event, @Nonnull TaskListener listener) throws IOException, InterruptedException {
List<Action> actions = new ArrayList<>();
actions.add(new GitLabSCMPublishAction(head, source.getSourceSettings()));
Action linkAction;
if (head instanceof ChangeRequestSCMHead) {
GitLabMergeRequest mr = retrieveMergeRequest((ChangeRequestSCMHead) head, listener);
linkAction = GitLabLinkAction.toMergeRequest(mr.getWebUrl());
if (acceptMergeRequest(head)) {
boolean removeSourceBranch = mr.getRemoveSourceBranch() || removeSourceBranch(head);
actions.add(new GitLabSCMAcceptMergeRequestAction(mr.getProjectId(), mr.getId(), mr.getIid(), source.getSourceSettings().getMergeCommitMessage(), removeSourceBranch));
}
} else {
linkAction = (head instanceof TagSCMHead) ? GitLabLinkAction.toTag(source.getProject(), head.getName()) : GitLabLinkAction.toBranch(source.getProject(), head.getName());
if (head instanceof GitLabSCMBranchHead && StringUtils.equals(source.getProject().getDefaultBranch(), head.getName())) {
actions.add(new PrimaryInstanceMetadataAction());
}
}
actions.add(linkAction);
return actions;
}
use of jenkins.scm.api.metadata.PrimaryInstanceMetadataAction in project blueocean-plugin by jenkinsci.
the class BranchImpl method getBranch.
@Exported(name = BRANCH, inline = true)
public Branch getBranch() {
ObjectMetadataAction om = job.getAction(ObjectMetadataAction.class);
PrimaryInstanceMetadataAction pima = job.getAction(PrimaryInstanceMetadataAction.class);
String url = om != null && om.getObjectUrl() != null ? om.getObjectUrl() : null;
return new Branch(url, pima != null);
}
Aggregations