Search in sources :

Example 1 with GitLabSCMHead

use of argelbargel.jenkins.plugins.gitlab_branch_source.heads.GitLabSCMHead in project gitlab-branch-source-plugin by Argelbargel.

the class GitLabSCMSource method build.

@Nonnull
@Override
public SCM build(@Nonnull SCMHead head, @CheckForNull SCMRevision revision) {
    GitSCM scm;
    if (head instanceof GitLabSCMHead) {
        scm = ((GitLabSCMHead) head).createSCM(this);
        if (revision instanceof SCMRevisionImpl) {
            scm.getExtensions().add(new BuildChooserSetting(new SpecificRevisionBuildChooser((SCMRevisionImpl) revision)));
        }
    } else {
        scm = (GitSCM) super.build(head, revision);
        scm.setBrowser(getBrowser());
    }
    return scm;
}
Also used : BuildChooserSetting(hudson.plugins.git.extensions.impl.BuildChooserSetting) GitSCM(hudson.plugins.git.GitSCM) GitLabSCMHead(argelbargel.jenkins.plugins.gitlab_branch_source.heads.GitLabSCMHead) Nonnull(javax.annotation.Nonnull)

Example 2 with GitLabSCMHead

use of argelbargel.jenkins.plugins.gitlab_branch_source.heads.GitLabSCMHead 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;
}
Also used : GitLabSCMPublishAction(argelbargel.jenkins.plugins.gitlab_branch_source.actions.GitLabSCMPublishAction) GitLabSCMCauseAction(argelbargel.jenkins.plugins.gitlab_branch_source.actions.GitLabSCMCauseAction) ObjectMetadataAction(jenkins.scm.api.metadata.ObjectMetadataAction) GitLabSCMAcceptMergeRequestAction(argelbargel.jenkins.plugins.gitlab_branch_source.actions.GitLabSCMAcceptMergeRequestAction) Action(hudson.model.Action) GitLabProjectAvatarMetadataAction(argelbargel.jenkins.plugins.gitlab_branch_source.actions.GitLabProjectAvatarMetadataAction) PrimaryInstanceMetadataAction(jenkins.scm.api.metadata.PrimaryInstanceMetadataAction) GitLabSCMHeadMetadataAction(argelbargel.jenkins.plugins.gitlab_branch_source.actions.GitLabSCMHeadMetadataAction) GitLabLinkAction(argelbargel.jenkins.plugins.gitlab_branch_source.actions.GitLabLinkAction) ContributorMetadataAction(jenkins.scm.api.metadata.ContributorMetadataAction) TagSCMHead(jenkins.scm.api.mixin.TagSCMHead) SCMHead(jenkins.scm.api.SCMHead) ChangeRequestSCMHead(jenkins.scm.api.mixin.ChangeRequestSCMHead) GitLabSCMHead(argelbargel.jenkins.plugins.gitlab_branch_source.heads.GitLabSCMHead) GitLabSCMCauseAction(argelbargel.jenkins.plugins.gitlab_branch_source.actions.GitLabSCMCauseAction) ArrayList(java.util.ArrayList) GitLabSCMMergeRequestHead(argelbargel.jenkins.plugins.gitlab_branch_source.heads.GitLabSCMMergeRequestHead) GitLabSCMHead(argelbargel.jenkins.plugins.gitlab_branch_source.heads.GitLabSCMHead) GitLabSCMEvent(argelbargel.jenkins.plugins.gitlab_branch_source.events.GitLabSCMEvent) Nonnull(javax.annotation.Nonnull)

Example 3 with GitLabSCMHead

use of argelbargel.jenkins.plugins.gitlab_branch_source.heads.GitLabSCMHead 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

GitLabSCMHead (argelbargel.jenkins.plugins.gitlab_branch_source.heads.GitLabSCMHead)3 GitLabSCMMergeRequestHead (argelbargel.jenkins.plugins.gitlab_branch_source.heads.GitLabSCMMergeRequestHead)2 ArrayList (java.util.ArrayList)2 Nonnull (javax.annotation.Nonnull)2 GitLabLinkAction (argelbargel.jenkins.plugins.gitlab_branch_source.actions.GitLabLinkAction)1 GitLabProjectAvatarMetadataAction (argelbargel.jenkins.plugins.gitlab_branch_source.actions.GitLabProjectAvatarMetadataAction)1 GitLabSCMAcceptMergeRequestAction (argelbargel.jenkins.plugins.gitlab_branch_source.actions.GitLabSCMAcceptMergeRequestAction)1 GitLabSCMCauseAction (argelbargel.jenkins.plugins.gitlab_branch_source.actions.GitLabSCMCauseAction)1 GitLabSCMHeadMetadataAction (argelbargel.jenkins.plugins.gitlab_branch_source.actions.GitLabSCMHeadMetadataAction)1 GitLabSCMPublishAction (argelbargel.jenkins.plugins.gitlab_branch_source.actions.GitLabSCMPublishAction)1 GitLabSCMEvent (argelbargel.jenkins.plugins.gitlab_branch_source.events.GitLabSCMEvent)1 MergeRequestObjectAttributes (com.dabsquared.gitlabjenkins.gitlab.hook.model.MergeRequestObjectAttributes)1 Action (hudson.model.Action)1 GitSCM (hudson.plugins.git.GitSCM)1 BuildChooserSetting (hudson.plugins.git.extensions.impl.BuildChooserSetting)1 SCMHead (jenkins.scm.api.SCMHead)1 ContributorMetadataAction (jenkins.scm.api.metadata.ContributorMetadataAction)1 ObjectMetadataAction (jenkins.scm.api.metadata.ObjectMetadataAction)1 PrimaryInstanceMetadataAction (jenkins.scm.api.metadata.PrimaryInstanceMetadataAction)1 ChangeRequestSCMHead (jenkins.scm.api.mixin.ChangeRequestSCMHead)1