use of jenkins.scm.api.SCMHead in project blueocean-plugin by jenkinsci.
the class BranchImpl method getPullRequest.
@Exported(name = PULL_REQUEST, inline = true)
public PullRequest getPullRequest() {
// TODO probably want to be using SCMHeadCategory instances to categorize them instead of hard-coding for PRs
SCMHead head = SCMHead.HeadByItem.findHead(job);
if (head instanceof ChangeRequestSCMHead) {
ChangeRequestSCMHead cr = (ChangeRequestSCMHead) head;
ObjectMetadataAction om = job.getAction(ObjectMetadataAction.class);
ContributorMetadataAction cm = job.getAction(ContributorMetadataAction.class);
return new PullRequest(cr.getId(), om != null ? om.getObjectUrl() : null, om != null ? om.getObjectDisplayName() : null, cm != null ? cm.getContributor() : null);
}
return null;
}
use of jenkins.scm.api.SCMHead in project gitlab-branch-source-plugin by Argelbargel.
the class SourceActions method retrieve.
@Nonnull
private List<Action> retrieve(@Nonnull SCMRevisionImpl revision, @CheckForNull SCMHeadEvent event, @Nonnull TaskListener listener) throws IOException, InterruptedException {
List<Action> actions = new ArrayList<>();
String hash = revision.getHash();
Action linkAction = GitLabLinkAction.toCommit(source.getProject(), hash);
actions.add(linkAction);
SCMHead head = revision.getHead();
if (head instanceof GitLabSCMMergeRequestHead) {
actions.add(createHeadMetadataAction(head.getName(), ((GitLabSCMMergeRequestHead) head).getSource(), hash, linkAction.getUrlName()));
} else if (head instanceof GitLabSCMHead) {
actions.add(createHeadMetadataAction(head.getName(), (GitLabSCMHead) head, hash, linkAction.getUrlName()));
}
if (event instanceof GitLabSCMEvent) {
actions.add(new GitLabSCMCauseAction(((GitLabSCMEvent) event).getCause()));
}
return actions;
}
Aggregations