jenkins.scm.api.mixin.TagSCMHead Java Examples

The following examples show how to use jenkins.scm.api.mixin.TagSCMHead. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NamedBranchBuildStrategyImpl.java    From basic-branch-build-strategies-plugin with MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean isAutomaticBuild(@NonNull SCMSource source, @NonNull SCMHead head, @NonNull SCMRevision currRevision,
                                @CheckForNull SCMRevision lastBuiltRevision, @CheckForNull SCMRevision lastSeenRevision, @NonNull TaskListener taskListener) {
    if (head instanceof ChangeRequestSCMHead) {
        return false;
    }
    if (head instanceof TagSCMHead) {
        return false;
    }
    String name = head.getName();
    for (NameFilter filter: filters) {
        if (filter.isMatch(name)) {
            return true;
        }
    }
    return false;
}
 
Example #2
Source File: TagBuildStrategyImpl.java    From basic-branch-build-strategies-plugin with MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean isAutomaticBuild(@NonNull SCMSource source, @NonNull SCMHead head, @NonNull SCMRevision currRevision,
                                @CheckForNull SCMRevision lastBuiltRevision, @CheckForNull SCMRevision lastSeenRevision, @NonNull  TaskListener taskListener) {
    if (!(head instanceof TagSCMHead)) {
        return false;
    }
    if (atLeastMillis >= 0L || atMostMillis >= 0L) {
        if (atMostMillis >= 0L && atLeastMillis > atMostMillis) {
            // stupid configuration that corresponds to never building anything, why did the user add it against
            // our advice?
            return false;
        }
        long tagAge = System.currentTimeMillis() - ((TagSCMHead)head).getTimestamp();
        if (atMostMillis >= 0L && tagAge > atMostMillis) {
            return false;
        }
        if (atLeastMillis >= 0L && tagAge < atLeastMillis) {
            return false;
        }
    }
    return true;
}
 
Example #3
Source File: GitLabSCMBranchBuildStrategy.java    From gitlab-branch-source-plugin with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("SimplifiableIfStatement")
private boolean isAutomaticBuild(GitLabSCMSource source, SCMHead head) {
    if (head instanceof TagSCMHead) {
        return source.getSourceSettings().getTagMonitorStrategy().getBuild();
    }

    if (head instanceof GitLabSCMBranchHead) {
        return !((GitLabSCMBranchHead) head).hasMergeRequest() || source.getSourceSettings().getBranchMonitorStrategy().getBuildBranchesWithMergeRequests();
    }

    if (head instanceof GitLabSCMMergeRequestHead) {
        return isAutomaticBuild(source, (GitLabSCMMergeRequestHead) head);
    }

    return true;
}
 
Example #4
Source File: BranchBuildStrategyImpl.java    From basic-branch-build-strategies-plugin with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean isAutomaticBuild(@NonNull SCMSource source, @NonNull SCMHead head, @NonNull SCMRevision currRevision,
                                @CheckForNull SCMRevision lastBuiltRevision, @CheckForNull SCMRevision lastSeenRevision, @NonNull TaskListener taskListener) {
    if (head instanceof ChangeRequestSCMHead) {
        return false;
    }
    if (head instanceof TagSCMHead) {
        return false;
    }
    return true;
}
 
Example #5
Source File: GitLabSCMBranchBuildStrategy.java    From gitlab-branch-source-plugin with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean isAutomaticBuild(SCMSource source, SCMHead head) {
    if (source instanceof GitLabSCMSource) {
        return isAutomaticBuild((GitLabSCMSource) source, head);
    }
    return !TagSCMHead.class.isInstance(head);
}
 
Example #6
Source File: GitLabSCMBranchBuildStrategy.java    From gitlab-branch-source-plugin with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean isAutomaticBuild(SCMSource source, SCMHead head, SCMRevision var3,  SCMRevision var4) {
    if (source instanceof GitLabSCMSource) {
        return isAutomaticBuild((GitLabSCMSource) source, head);
    }
    return !TagSCMHead.class.isInstance(head);
}
 
Example #7
Source File: GitLabSCMSourceSettings.java    From gitlab-branch-source-plugin with GNU General Public License v2.0 5 votes vote down vote up
@Restricted(NoExternalUse.class)
public BuildStatusPublishMode determineBuildStatusPublishMode(SCMHead head) {
    if (head instanceof GitLabSCMMergeRequestHead) {
        return ((GitLabSCMMergeRequestHead) head).fromOrigin()
                ? originMonitorStrategy.getBuildStatusPublishMode()
                : forksMonitorStrategy.getBuildStatusPublishMode();
    } else if (head instanceof TagSCMHead) {
        return tagMonitorStrategy.getBuildStatusPublishMode();
    }

    return branchMonitorStrategy.getBuildStatusPublishMode();
}
 
Example #8
Source File: SourceActions.java    From gitlab-branch-source-plugin with GNU General Public License v2.0 5 votes vote down vote up
@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());
        actions.add(createAuthorMetadataAction(mr));
        actions.add(createHeadMetadataAction(((GitLabSCMMergeRequestHead) head).getDescription(), ((GitLabSCMMergeRequestHead) head).getSource(), null, linkAction.getUrlName()));
        if (acceptMergeRequest(head)) {
            boolean removeSourceBranch = mr.getRemoveSourceBranch() || removeSourceBranch(head);
            actions.add(new GitLabSCMAcceptMergeRequestAction(mr, 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;
}
 
Example #9
Source File: GitHubSCMBuilder.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
/**
 * Constructor.
 *
 * @param source   the {@link GitHubSCMSource}.
 * @param head     the {@link SCMHead}
 * @param revision the (optional) {@link SCMRevision}
 */
public GitHubSCMBuilder(@NonNull GitHubSCMSource source,
                        @NonNull SCMHead head, @CheckForNull SCMRevision revision) {
    super(head, revision, /*dummy value*/guessRemote(source), source.getCredentialsId());
    this.context = source.getOwner();
    apiUri = StringUtils.defaultIfBlank(source.getApiUri(), GitHubServerConfig.GITHUB_URL);
    repoOwner = source.getRepoOwner();
    repository = source.getRepository();
    repositoryUrl = source.getResolvedRepositoryUrl();
    // now configure the ref specs
    withoutRefSpecs();
    String repoUrl;
    if (head instanceof PullRequestSCMHead) {
        PullRequestSCMHead h = (PullRequestSCMHead) head;
        withRefSpec("+refs/pull/" + h.getId() + "/head:refs/remotes/@{remote}/" + head
                .getName());
        repoUrl = repositoryUrl(h.getSourceOwner(), h.getSourceRepo());
    } else if (head instanceof TagSCMHead) {
        withRefSpec("+refs/tags/" + head.getName() + ":refs/tags/" + head.getName());
        repoUrl = repositoryUrl(repoOwner, repository);
    } else {
        withRefSpec("+refs/heads/" + head.getName() + ":refs/remotes/@{remote}/" + head.getName());
        repoUrl = repositoryUrl(repoOwner, repository);
    }
    // pre-configure the browser
    if (repoUrl != null) {
        withBrowser(new GithubWeb(repoUrl));
    }
    withCredentials(credentialsId(), null);
}