Search in sources :

Example 1 with MergeRequestObjectAttributes

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);
        }
    }
}
Also used : GitLabMergeRequest(argelbargel.jenkins.plugins.gitlab_branch_source.api.GitLabMergeRequest) MergeRequestObjectAttributes(com.dabsquared.gitlabjenkins.gitlab.hook.model.MergeRequestObjectAttributes) NoSuchElementException(java.util.NoSuchElementException)

Example 2 with MergeRequestObjectAttributes

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;
}
Also used : ArrayList(java.util.ArrayList) MergeRequestObjectAttributes(com.dabsquared.gitlabjenkins.gitlab.hook.model.MergeRequestObjectAttributes) GitLabSCMMergeRequestHead(argelbargel.jenkins.plugins.gitlab_branch_source.heads.GitLabSCMMergeRequestHead) GitLabSCMHead(argelbargel.jenkins.plugins.gitlab_branch_source.heads.GitLabSCMHead)

Aggregations

MergeRequestObjectAttributes (com.dabsquared.gitlabjenkins.gitlab.hook.model.MergeRequestObjectAttributes)2 GitLabMergeRequest (argelbargel.jenkins.plugins.gitlab_branch_source.api.GitLabMergeRequest)1 GitLabSCMHead (argelbargel.jenkins.plugins.gitlab_branch_source.heads.GitLabSCMHead)1 GitLabSCMMergeRequestHead (argelbargel.jenkins.plugins.gitlab_branch_source.heads.GitLabSCMMergeRequestHead)1 ArrayList (java.util.ArrayList)1 NoSuchElementException (java.util.NoSuchElementException)1