jenkins.scm.api.trait.SCMHeadAuthority Java Examples

The following examples show how to use jenkins.scm.api.trait.SCMHeadAuthority. 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: ForkPullRequestDiscoveryTrait.java    From gitea-plugin with MIT License 5 votes vote down vote up
/**
 * Returns the list of appropriate {@link SCMHeadAuthorityDescriptor} instances.
 *
 * @return the list of appropriate {@link SCMHeadAuthorityDescriptor} instances.
 */
@NonNull
@SuppressWarnings("unused") // stapler
public List<SCMHeadAuthorityDescriptor> getTrustDescriptors() {
    return SCMHeadAuthority._for(
            GiteaSCMSourceRequest.class,
            PullRequestSCMHead.class,
            PullRequestSCMRevision.class,
            SCMHeadOrigin.Fork.class
    );
}
 
Example #2
Source File: ForkPullRequestDiscoveryTrait2Test.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
private void assertRoundTrip(WorkflowMultiBranchProject p, SCMHeadAuthority<? super GitHubSCMSourceRequest, ? extends ChangeRequestSCMHead2, ? extends SCMRevision> trust, boolean configuredByUrl) throws Exception {

        GitHubSCMSource s;
        if (configuredByUrl)
            s = new GitHubSCMSource("", "", "https://github.com/nobody/nowhere", true);
        else
            s = new GitHubSCMSource("nobody", "nowhere", null, false);

        p.setSourcesList(Collections.singletonList(new BranchSource(s)));
        s.setTraits(Collections.singletonList(new ForkPullRequestDiscoveryTrait(0, trust)));
        r.configRoundtrip(p);
        List<SCMSourceTrait> traits = ((GitHubSCMSource) p.getSourcesList().get(0).getSource()).getTraits();
        assertEquals(1, traits.size());
        assertEquals(trust.getClass(), ((ForkPullRequestDiscoveryTrait) traits.get(0)).getTrust().getClass());
    }
 
Example #3
Source File: TagDiscoveryTraitTest.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
@Test
public void decorateContext() throws Exception {
    GitHubSCMSourceContext probe = new GitHubSCMSourceContext(null, SCMHeadObserver.collect());
    assertThat(probe.wantBranches(), is(false));
    assertThat(probe.wantPRs(), is(false));
    assertThat(probe.wantTags(), is(false));
    assertThat(probe.authorities(), is(Collections.<SCMHeadAuthority<?, ?, ?>>emptyList()));
    new TagDiscoveryTrait().applyToContext(probe);
    assertThat(probe.wantBranches(), is(false));
    assertThat(probe.wantPRs(), is(false));
    assertThat(probe.wantTags(), is(true));
    assertThat(probe.authorities(), contains(instanceOf(TagDiscoveryTrait.TagSCMHeadAuthority.class)));
}
 
Example #4
Source File: ForkPullRequestDiscoveryTrait.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
/**
 * Returns the list of appropriate {@link SCMHeadAuthorityDescriptor} instances.
 *
 * @return the list of appropriate {@link SCMHeadAuthorityDescriptor} instances.
 */
@NonNull
@SuppressWarnings("unused") // stapler
public List<SCMHeadAuthorityDescriptor> getTrustDescriptors() {
    return SCMHeadAuthority._for(
            GitHubSCMSourceRequest.class,
            PullRequestSCMHead.class,
            PullRequestSCMRevision.class,
            SCMHeadOrigin.Fork.class
    );
}
 
Example #5
Source File: ForkPullRequestDiscoveryTrait.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
/**
 * Constructor for stapler.
 *
 * @param strategyId the strategy id.
 * @param trust      the authority to use.
 */
@DataBoundConstructor
public ForkPullRequestDiscoveryTrait(int strategyId,
                                     @NonNull SCMHeadAuthority<? super GitHubSCMSourceRequest, ? extends ChangeRequestSCMHead2, ? extends SCMRevision> trust) {
    this.strategyId = strategyId;
    this.trust = trust;
}
 
Example #6
Source File: ForkMergeRequestDiscoveryTrait.java    From gitlab-branch-source-plugin with MIT License 5 votes vote down vote up
/**
 * Constructor for stapler.
 *
 * @param strategyId the strategy id.
 * @param trust the authority to use.
 */
@DataBoundConstructor
public ForkMergeRequestDiscoveryTrait(int strategyId,
    @NonNull SCMHeadAuthority<? super GitLabSCMSourceRequest, ? extends
        ChangeRequestSCMHead2, ? extends SCMRevision> trust) {
    this.strategyId = strategyId;
    this.trust = trust;
}
 
Example #7
Source File: ForkPullRequestDiscoveryTrait.java    From gitea-plugin with MIT License 5 votes vote down vote up
/**
 * Constructor for programmatic instantiation.
 *
 * @param strategies the {@link ChangeRequestCheckoutStrategy} instances.
 * @param trust      the authority.
 */
public ForkPullRequestDiscoveryTrait(@NonNull Set<ChangeRequestCheckoutStrategy> strategies,
                                     @NonNull SCMHeadAuthority<? super GiteaSCMSourceRequest, ? extends
                                             ChangeRequestSCMHead2, ? extends SCMRevision> trust) {
    this((strategies.contains(ChangeRequestCheckoutStrategy.MERGE) ? 1 : 0)
            + (strategies.contains(ChangeRequestCheckoutStrategy.HEAD) ? 2 : 0), trust);
}
 
Example #8
Source File: ForkPullRequestDiscoveryTrait.java    From gitea-plugin with MIT License 5 votes vote down vote up
/**
 * Constructor for stapler.
 *
 * @param strategyId the strategy id.
 * @param trust      the authority to use.
 */
@DataBoundConstructor
public ForkPullRequestDiscoveryTrait(int strategyId,
                                     @NonNull SCMHeadAuthority<? super GiteaSCMSourceRequest, ? extends
                                             ChangeRequestSCMHead2, ? extends SCMRevision> trust) {
    this.strategyId = strategyId;
    this.trust = trust;
}
 
Example #9
Source File: ForkMergeRequestDiscoveryTrait.java    From gitlab-branch-source-plugin with MIT License 5 votes vote down vote up
/**
 * Returns the list of appropriate {@link SCMHeadAuthorityDescriptor} instances.
 *
 * @return the list of appropriate {@link SCMHeadAuthorityDescriptor} instances.
 */
@NonNull
@SuppressWarnings("unused") // stapler
public List<SCMHeadAuthorityDescriptor> getTrustDescriptors() {
    return SCMHeadAuthority._for(
        GitLabSCMSourceRequest.class,
        MergeRequestSCMHead.class,
        MergeRequestSCMRevision.class,
        SCMHeadOrigin.Fork.class
    );
}
 
Example #10
Source File: ForkMergeRequestDiscoveryTrait.java    From gitlab-branch-source-plugin with MIT License 5 votes vote down vote up
/**
 * Constructor for programmatic instantiation.
 *
 * @param strategies the {@link ChangeRequestCheckoutStrategy} instances.
 * @param trust the authority.
 */
public ForkMergeRequestDiscoveryTrait(@NonNull Set<ChangeRequestCheckoutStrategy> strategies,
    @NonNull SCMHeadAuthority<? super GitLabSCMSourceRequest, ? extends
        ChangeRequestSCMHead2, ? extends SCMRevision> trust) {
    this((strategies.contains(ChangeRequestCheckoutStrategy.MERGE) ? 1 : 0)
        + (strategies.contains(ChangeRequestCheckoutStrategy.HEAD) ? 2 : 0), trust);
}
 
Example #11
Source File: ForkPullRequestDiscoveryTrait.java    From gitea-plugin with MIT License 4 votes vote down vote up
/**
 * Gets the authority.
 *
 * @return the authority.
 */
@NonNull
public SCMHeadAuthority<? super GiteaSCMSourceRequest, ? extends ChangeRequestSCMHead2, ? extends SCMRevision>
getTrust() {
    return trust;
}
 
Example #12
Source File: ForkPullRequestDiscoveryTrait.java    From gitea-plugin with MIT License 4 votes vote down vote up
/**
 * Returns the default trust for new instances of {@link ForkPullRequestDiscoveryTrait}.
 *
 * @return the default trust for new instances of {@link ForkPullRequestDiscoveryTrait}.
 */
@NonNull
@SuppressWarnings("unused") // stapler
public SCMHeadAuthority<?, ?, ?> getDefaultTrust() {
    return new TrustContributors();
}
 
Example #13
Source File: ForkMergeRequestDiscoveryTrait.java    From gitlab-branch-source-plugin with MIT License 4 votes vote down vote up
/**
 * Returns the default trust for new instances of {@link ForkMergeRequestDiscoveryTrait}.
 *
 * @return the default trust for new instances of {@link ForkMergeRequestDiscoveryTrait}.
 */
@NonNull
@SuppressWarnings("unused") // stapler
public SCMHeadAuthority<?, ?, ?> getDefaultTrust() {
    return new TrustPermission();
}
 
Example #14
Source File: ForkPullRequestDiscoveryTrait.java    From github-branch-source-plugin with MIT License 4 votes vote down vote up
/**
 * Returns the default trust for new instances of {@link ForkPullRequestDiscoveryTrait}.
 *
 * @return the default trust for new instances of {@link ForkPullRequestDiscoveryTrait}.
 */
@NonNull
@SuppressWarnings("unused") // stapler
public SCMHeadAuthority<?, ?, ?> getDefaultTrust() {
    return new TrustPermission();
}
 
Example #15
Source File: ForkMergeRequestDiscoveryTrait.java    From gitlab-branch-source-plugin with MIT License 4 votes vote down vote up
/**
 * Gets the authority.
 *
 * @return the authority.
 */
@NonNull
public SCMHeadAuthority<? super GitLabSCMSourceRequest, ? extends ChangeRequestSCMHead2, ? extends SCMRevision>
getTrust() {
    return trust;
}
 
Example #16
Source File: ForkPullRequestDiscoveryTrait.java    From github-branch-source-plugin with MIT License 2 votes vote down vote up
/**
 * Constructor for programmatic instantiation.
 *
 * @param strategies the {@link ChangeRequestCheckoutStrategy} instances.
 * @param trust      the authority.
 */
public ForkPullRequestDiscoveryTrait(@NonNull Set<ChangeRequestCheckoutStrategy> strategies,
                                     @NonNull SCMHeadAuthority<? super GitHubSCMSourceRequest, ? extends ChangeRequestSCMHead2, ? extends SCMRevision> trust) {
    this((strategies.contains(ChangeRequestCheckoutStrategy.MERGE) ? 1 : 0)
            + (strategies.contains(ChangeRequestCheckoutStrategy.HEAD) ? 2 : 0), trust);
}
 
Example #17
Source File: ForkPullRequestDiscoveryTrait.java    From github-branch-source-plugin with MIT License 2 votes vote down vote up
/**
 * Gets the authority.
 *
 * @return the authority.
 */
@NonNull
public SCMHeadAuthority<? super GitHubSCMSourceRequest, ? extends ChangeRequestSCMHead2, ? extends SCMRevision> getTrust() {
    return trust;
}