use of com.dabsquared.gitlabjenkins.gitlab.hook.model.MergeRequestObjectAttributes in project gitlab-branch-source-plugin by Argelbargel.
the class SourceHeads method retrieveMergeRequest.
private void retrieveMergeRequest(SCMSourceCriteria criteria, @Nonnull SCMHeadObserver observer, @Nonnull GitLabSCMMergeRequestEvent event, @Nonnull TaskListener listener) throws IOException, InterruptedException {
MergeRequestObjectAttributes attributes = event.getPayload().getObjectAttributes();
String targetBranch = attributes.getTargetBranch();
if (!source.isExcluded(targetBranch)) {
int mrId = attributes.getIid();
log(listener, Messages.GitLabSCMSource_retrievingMergeRequest(mrId));
try {
GitLabMergeRequest mr = api().getMergeRequest(source.getProjectId(), mrId);
observe(criteria, observer, mr, listener);
} catch (NoSuchElementException e) {
log(listener, Messages.GitLabSCMSource_removedMergeRequest(mrId));
branchesWithMergeRequests(listener).remove(mrId);
}
}
}
use of com.dabsquared.gitlabjenkins.gitlab.hook.model.MergeRequestObjectAttributes in project gitlab-branch-source-plugin by Argelbargel.
the class GitLabSCMMergeRequestEvent method heads.
@Override
Collection<? extends GitLabSCMHead> heads(@Nonnull GitLabSCMSource source) throws IOException, InterruptedException {
Collection<GitLabSCMHead> heads = new ArrayList<>();
MergeRequestObjectAttributes attributes = getAttributes();
Integer sourceProjectId = attributes.getSourceProjectId();
String sourceBranch = attributes.getSourceBranch();
String hash = attributes.getLastCommit().getId();
GitLabSCMMergeRequestHead head = createMergeRequest(attributes.getIid(), attributes.getTitle(), attributes.getIid(), createBranch(sourceProjectId, sourceBranch, hash), createBranch(attributes.getTargetProjectId(), attributes.getTargetBranch(), REVISION_HEAD));
if (source.getSourceSettings().buildUnmerged(head)) {
heads.add(head);
}
if (source.getSourceSettings().buildMerged(head)) {
heads.add(head.merged());
}
if (head.fromOrigin()) {
heads.add(createBranch(sourceProjectId, sourceBranch, hash));
}
return heads;
}
Aggregations