jenkins.scm.api.SCMSource Java Examples

The following examples show how to use jenkins.scm.api.SCMSource. 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: NoneBranchBuildStrategyImpl.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(strategies.isEmpty()){
        return false;
    }

    for (BranchBuildStrategy strategy: strategies) {
        if(strategy.automaticBuild(
            source,
            head,
            currRevision,
            lastBuiltRevision,
            lastSeenRevision,
            taskListener
        )){
            return false;
        };

    }
    return true;
}
 
Example #2
Source File: MultiBranchTest.java    From blueocean-plugin with MIT License 6 votes vote down vote up
@Test
public void multiBranchPipelineIndex() throws Exception {
    User user = login();
    WorkflowMultiBranchProject mp = j.jenkins.createProject(WorkflowMultiBranchProject.class, "p");
    mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", false),
            new DefaultBranchPropertyStrategy(new BranchProperty[0])));
    for (SCMSource source : mp.getSCMSources()) {
        assertEquals(mp, source.getOwner());
    }

    Map map = new RequestBuilder(baseUrl)
            .post("/organizations/jenkins/pipelines/p/runs/")
            .jwtToken(getJwtToken(j.jenkins, user.getId(), user.getId()))
            .crumb( getCrumb( j.jenkins ) )
            .data(ImmutableMap.of())
            .status(200)
            .build(Map.class);

    assertNotNull(map);
}
 
Example #3
Source File: MultiBranchTest.java    From blueocean-plugin with MIT License 6 votes vote down vote up
@Test
public void getMultiBranchPipelineRunStages() throws Exception {
    WorkflowMultiBranchProject mp = j.jenkins.createProject(WorkflowMultiBranchProject.class, "p");
    mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", false),
        new DefaultBranchPropertyStrategy(new BranchProperty[0])));
    for (SCMSource source : mp.getSCMSources()) {
        assertEquals(mp, source.getOwner());
    }

    WorkflowJob p = scheduleAndFindBranchProject(mp, "master");


    j.waitUntilNoActivity();
    WorkflowRun b1 = p.getLastBuild();
    assertEquals(1, b1.getNumber());
    assertEquals(3, mp.getItems().size());

    j.waitForCompletion(b1);

    List<Map> nodes = get("/organizations/jenkins/pipelines/p/branches/master/runs/1/nodes", List.class);

    Assert.assertEquals(3, nodes.size());
}
 
Example #4
Source File: Functions.java    From github-integration-plugin with MIT License 6 votes vote down vote up
public static <ITEM extends Item> Predicate<ITEM> withBranchHandler() {
    return item -> {
        if (item instanceof SCMSourceOwner) {
            SCMSourceOwner scmSourceOwner = (SCMSourceOwner) item;
            for (SCMSource source : scmSourceOwner.getSCMSources()) {
                if (source instanceof GitHubSCMSource) {
                    GitHubSCMSource gitHubSCMSource = (GitHubSCMSource) source;
                    for (GitHubHandler hubHandler : gitHubSCMSource.getHandlers()) {
                        if (hubHandler instanceof GitHubBranchHandler) {
                            return true;
                        }
                    }
                }
            }
        }
        return false;
    };
}
 
Example #5
Source File: MultiBranchTest.java    From blueocean-plugin with MIT License 6 votes vote down vote up
@Test
public void startMultiBranchPipelineRuns() throws Exception {
    WorkflowMultiBranchProject mp = j.jenkins.createProject(WorkflowMultiBranchProject.class, "p");
    mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", false),
        new DefaultBranchPropertyStrategy(new BranchProperty[0])));
    for (SCMSource source : mp.getSCMSources()) {
        assertEquals(mp, source.getOwner());
    }
    WorkflowJob p = scheduleAndFindBranchProject(mp, "feature%2Fux-1");
    j.waitUntilNoActivity();

    Map resp = post("/organizations/jenkins/pipelines/p/branches/"+ Util.rawEncode("feature%2Fux-1")+"/runs/",
        Collections.EMPTY_MAP);
    String id = (String) resp.get("id");
    String link = getHrefFromLinks(resp, "self");
    Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/p/branches/feature%252Fux-1/runs/"+id+"/", link);
}
 
Example #6
Source File: MultiBranchTest.java    From blueocean-plugin with MIT License 6 votes vote down vote up
@Test
public void getMultiBranchPipelineInsideFolder() throws IOException, ExecutionException, InterruptedException {
    MockFolder folder1 = j.createFolder("folder1");
    WorkflowMultiBranchProject mp = folder1.createProject(WorkflowMultiBranchProject.class, "p");
    mp.setDisplayName("My MBP");

    mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", false),
        new DefaultBranchPropertyStrategy(new BranchProperty[0])));
    for (SCMSource source : mp.getSCMSources()) {
        assertEquals(mp, source.getOwner());
    }

    mp.scheduleBuild2(0).getFuture().get();

    Map r = get("/organizations/jenkins/pipelines/folder1/pipelines/p/");

    validateMultiBranchPipeline(mp, r, 3);
    Assert.assertEquals("/blue/rest/organizations/jenkins/pipelines/folder1/pipelines/p/",
        ((Map)((Map)r.get("_links")).get("self")).get("href"));
    Assert.assertEquals("folder1/My%20MBP", r.get("fullDisplayName"));
    r = get("/organizations/jenkins/pipelines/folder1/pipelines/p/master/");
    Assert.assertEquals("folder1/My%20MBP/master", r.get("fullDisplayName"));
}
 
Example #7
Source File: BitbucketServerScmContentProviderTest.java    From blueocean-plugin with MIT License 6 votes vote down vote up
private MultiBranchProject mockMbp(String credentialId, User user) {
    MultiBranchProject mbp = mock(MultiBranchProject.class);
    when(mbp.getName()).thenReturn("pipeline1");
    when(mbp.getParent()).thenReturn(j.jenkins);
    BitbucketSCMSource scmSource = mock(BitbucketSCMSource.class);
    when(scmSource.getServerUrl()).thenReturn(apiUrl);
    when(scmSource.getCredentialsId()).thenReturn(credentialId);
    when(scmSource.getRepoOwner()).thenReturn("TESTP");
    when(scmSource.getRepository()).thenReturn("pipeline-demo-test");
    when(mbp.getSCMSources()).thenReturn(Lists.<SCMSource>newArrayList(scmSource));

    //mock blueocean credential provider stuff
    BlueOceanCredentialsProvider.FolderPropertyImpl folderProperty = mock(BlueOceanCredentialsProvider.FolderPropertyImpl.class);
    DescribableList<AbstractFolderProperty<?>, AbstractFolderPropertyDescriptor> properties = new DescribableList<AbstractFolderProperty<?>, AbstractFolderPropertyDescriptor>(mbp);
    properties.add(new BlueOceanCredentialsProvider.FolderPropertyImpl(
            user.getId(), credentialId,
            BlueOceanCredentialsProvider.createDomain(apiUrl)
    ));
    Domain domain = mock(Domain.class);
    when(domain.getName()).thenReturn(BitbucketServerScm.DOMAIN_NAME);
    when(folderProperty.getDomain()).thenReturn(domain);

    when(mbp.getProperties()).thenReturn(properties);
    return mbp;
}
 
Example #8
Source File: AllBranchBuildStrategyImpl.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(strategies.isEmpty()){
        return false;
    }

    for (BranchBuildStrategy strategy: strategies) {
        if(!strategy.automaticBuild(
            source,
            head,
            currRevision,
            lastBuiltRevision,
            lastSeenRevision,
            taskListener
        )){
            return false;
        };

    }
    return true;
}
 
Example #9
Source File: GithubIssue.java    From blueocean-plugin with MIT License 6 votes vote down vote up
@Override
public Collection<BlueIssue> getIssues(ChangeLogSet.Entry changeSetEntry) {
    Job job = changeSetEntry.getParent().getRun().getParent();
    if (!(job.getParent() instanceof MultiBranchProject)) {
        return null;
    }
    MultiBranchProject mbp = (MultiBranchProject)job.getParent();
    List<SCMSource> scmSources = (List<SCMSource>) mbp.getSCMSources();
    SCMSource source = scmSources.isEmpty() ? null : scmSources.get(0);
    if (!(source instanceof GitHubSCMSource)) {
        return null;
    }
    GitHubSCMSource gitHubSource = (GitHubSCMSource)source;
    String apiUri =  gitHubSource.getApiUri();
    final String repositoryUri = new HttpsRepositoryUriResolver().getRepositoryUri(apiUri, gitHubSource.getRepoOwner(), gitHubSource.getRepository());
    Collection<BlueIssue> results = new ArrayList<>();
    for (String input : findIssueKeys(changeSetEntry.getMsg())) {
        String uri = repositoryUri.substring(0, repositoryUri.length() - 4);
        results.add(new GithubIssue("#" + input, String.format("%s/issues/%s", uri, input)));
    }
    return results;
}
 
Example #10
Source File: PullRequestGHEventSubscriber.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
@Override
public String descriptionFor(SCMSource source) {
    String action = getPayload().getAction();
    if (action != null) {
        switch (action) {
            case "opened":
                return "Pull request #" + getPayload().getNumber() + " opened";
            case "reopened":
                return "Pull request #" + getPayload().getNumber() + " reopened";
            case "synchronize":
                return "Pull request #" + getPayload().getNumber() + " updated";
            case "closed":
                return "Pull request #" + getPayload().getNumber() + " closed";
        }
    }
    return "Pull request #" + getPayload().getNumber() + " event";
}
 
Example #11
Source File: AnyBranchBuildStrategyImpl.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(strategies.isEmpty()){
        return false;
    }

    for (BranchBuildStrategy strategy: strategies) {
        if(strategy.automaticBuild(
            source,
            head,
            currRevision,
            lastBuiltRevision,
            lastSeenRevision,
            taskListener
        )){
            return true;
        };

    }
    return false;
}
 
Example #12
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 #13
Source File: GithubPipelineCreateRequest.java    From blueocean-plugin with MIT License 6 votes vote down vote up
@Override
protected SCMSource createSource(@Nonnull MultiBranchProject project, @Nonnull BlueScmConfig scmConfig) {
    // Update endpoint only if its GitHub Enterprise
    if(scmConfig.getId().equals(GithubEnterpriseScm.ID)) {
        updateEndpoints(scmConfig.getUri());
    }

    Set<ChangeRequestCheckoutStrategy> strategies = new HashSet<>();
    strategies.add(ChangeRequestCheckoutStrategy.MERGE);

    return new GitHubSCMSourceBuilder(null, scmConfig.getUri(), computeCredentialId(scmConfig),
            (String)scmConfig.getConfig().get("repoOwner"),
            (String)scmConfig.getConfig().get("repository"))
            .withTrait(new BranchDiscoveryTrait(true, true)) //take all branches
            .withTrait(new ForkPullRequestDiscoveryTrait(strategies, new ForkPullRequestDiscoveryTrait.TrustPermission()))
            .withTrait(new OriginPullRequestDiscoveryTrait(strategies))
            .withTrait(new CleanBeforeCheckoutTrait())
            .withTrait(new CleanAfterCheckoutTrait())
            .withTrait(new LocalBranchTrait())
            .build();
}
 
Example #14
Source File: MultiBranchTest.java    From blueocean-plugin with MIT License 6 votes vote down vote up
@Test
public void getPipelinesTest() throws Exception {

    WorkflowMultiBranchProject mp = j.jenkins.createProject(WorkflowMultiBranchProject.class, "p");
    mp.getSourcesList().add(new BranchSource(new GitSCMSource(null, sampleRepo.toString(), "", "*", "", false),
        new DefaultBranchPropertyStrategy(new BranchProperty[0])));
    for (SCMSource source : mp.getSCMSources()) {
        assertEquals(mp, source.getOwner());
    }

    WorkflowJob p = scheduleAndFindBranchProject(mp, "master");


    j.waitUntilNoActivity();

    List<Map> responses = get("/search/?q=type:pipeline;excludedFromFlattening:jenkins.branch.MultiBranchProject", List.class);
    Assert.assertEquals(1, responses.size());
}
 
Example #15
Source File: ChangeRequestBuildStrategyImpl.java    From basic-branch-build-strategies-plugin with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Deprecated
@Override
public boolean isAutomaticBuild(@NonNull SCMSource source, @NonNull SCMHead head, @NonNull SCMRevision currRevision,
                                @CheckForNull SCMRevision prevRevision) {
    return isAutomaticBuild(source, head, currRevision, prevRevision, new LogTaskListener(Logger.getLogger(getClass().getName()), Level.INFO));
}
 
Example #16
Source File: ChangeRequestBuildStrategyImpl.java    From basic-branch-build-strategies-plugin with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Restricted(ProtectedExternally.class)
@Deprecated
@Override
public boolean isAutomaticBuild(@NonNull SCMSource source, @NonNull SCMHead head, @NonNull SCMRevision currRevision,
                                @CheckForNull SCMRevision prevRevision, @NonNull TaskListener taskListener) {
    return isAutomaticBuild(source,head, currRevision, prevRevision, prevRevision, taskListener);
}
 
Example #17
Source File: GiteaSCMSourceRequest.java    From gitea-plugin with MIT License 5 votes vote down vote up
/**
 * Constructor.
 *
 * @param source   the source.
 * @param context  the context.
 * @param listener the listener.
 */
GiteaSCMSourceRequest(SCMSource source, GiteaSCMSourceContext context, TaskListener listener) {
    super(source, context, listener);
    fetchBranches = context.wantBranches();
    fetchTags = context.wantTags();
    fetchOriginPRs = context.wantOriginPRs();
    fetchForkPRs = context.wantForkPRs();
    originPRStrategies = fetchOriginPRs && !context.originPRStrategies().isEmpty()
            ? Collections.unmodifiableSet(EnumSet.copyOf(context.originPRStrategies()))
            : Collections.<ChangeRequestCheckoutStrategy>emptySet();
    forkPRStrategies = fetchForkPRs && !context.forkPRStrategies().isEmpty()
            ? Collections.unmodifiableSet(EnumSet.copyOf(context.forkPRStrategies()))
            : Collections.<ChangeRequestCheckoutStrategy>emptySet();
    Set<SCMHead> includes = context.observer().getIncludes();
    if (includes != null) {
        Set<Long> pullRequestNumbers = new HashSet<>(includes.size());
        Set<String> branchNames = new HashSet<>(includes.size());
        Set<String> tagNames = new HashSet<>(includes.size());
        for (SCMHead h : includes) {
            if (h instanceof BranchSCMHead) {
                branchNames.add(h.getName());
            } else if (h instanceof PullRequestSCMHead) {
                pullRequestNumbers.add(Long.parseLong(((PullRequestSCMHead) h).getId()));
                if (SCMHeadOrigin.DEFAULT.equals(h.getOrigin())) {
                    branchNames.add(((PullRequestSCMHead) h).getOriginName());
                }
            } else if (h instanceof TagSCMHead) {
                tagNames.add(h.getName());
            }
        }
        this.requestedPullRequestNumbers = Collections.unmodifiableSet(pullRequestNumbers);
        this.requestedOriginBranchNames = Collections.unmodifiableSet(branchNames);
        this.requestedTagNames = Collections.unmodifiableSet(tagNames);
    } else {
        requestedPullRequestNumbers = null;
        requestedOriginBranchNames = null;
        requestedTagNames = null;
    }
}
 
Example #18
Source File: GitHubSCMSourceRequest.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
/**
 * Constructor.
 *
 * @param source   the source.
 * @param context  the context.
 * @param listener the listener.
 */
GitHubSCMSourceRequest(SCMSource source, GitHubSCMSourceContext context, TaskListener listener) {
    super(source, context, listener);
    fetchBranches = context.wantBranches();
    fetchTags = context.wantTags();
    fetchOriginPRs = context.wantOriginPRs();
    fetchForkPRs = context.wantForkPRs();
    originPRStrategies = fetchOriginPRs && !context.originPRStrategies().isEmpty()
            ? Collections.unmodifiableSet(EnumSet.copyOf(context.originPRStrategies()))
            : Collections.emptySet();
    forkPRStrategies = fetchForkPRs && !context.forkPRStrategies().isEmpty()
            ? Collections.unmodifiableSet(EnumSet.copyOf(context.forkPRStrategies()))
            : Collections.emptySet();
    Set<SCMHead> includes = context.observer().getIncludes();
    if (includes != null) {
        Set<Integer> pullRequestNumbers = new HashSet<>(includes.size());
        Set<String> branchNames = new HashSet<>(includes.size());
        Set<String> tagNames = new HashSet<>(includes.size());
        for (SCMHead h : includes) {
            if (h instanceof BranchSCMHead) {
                branchNames.add(h.getName());
            } else if (h instanceof PullRequestSCMHead) {
                pullRequestNumbers.add(((PullRequestSCMHead) h).getNumber());
                if (SCMHeadOrigin.DEFAULT.equals(h.getOrigin())) {
                    branchNames.add(((PullRequestSCMHead) h).getOriginName());
                }
            } else if (h instanceof GitHubTagSCMHead) {
                tagNames.add(h.getName());
            }
        }
        this.requestedPullRequestNumbers = Collections.unmodifiableSet(pullRequestNumbers);
        this.requestedOriginBranchNames = Collections.unmodifiableSet(branchNames);
        this.requestedTagNames = Collections.unmodifiableSet(tagNames);
    } else {
        requestedPullRequestNumbers = null;
        requestedOriginBranchNames = null;
        requestedTagNames = null;
    }
}
 
Example #19
Source File: AbstractGiteaSCMSourceEvent.java    From gitea-plugin with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean isMatch(@NonNull SCMSource source) {
    if (!(source instanceof GiteaSCMSource)) {
        return false;
    }
    GiteaSCMSource src = (GiteaSCMSource) source;
    return StringUtils.equalsIgnoreCase(getPayload().getRepository().getOwner().getUsername(), src.getRepoOwner())
            && StringUtils.equalsIgnoreCase(getPayload().getRepository().getName(), src.getRepository())
            && GiteaServers.isEventFor(src.getServerUrl(), getPayload().getRepository().getHtmlUrl());

}
 
Example #20
Source File: GitHubRepositoryEventSubscriber.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
@Override
public boolean isMatch(@NonNull SCMSource source) {
    return source instanceof GitHubSCMSource
            && isApiMatch(((GitHubSCMSource) source).getApiUri())
            && repoOwner.equalsIgnoreCase(((GitHubSCMSource) source).getRepoOwner())
            && repository.equalsIgnoreCase(((GitHubSCMSource) source).getRepository());
}
 
Example #21
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 #22
Source File: AnyBranchBuildStrategyImpl.java    From basic-branch-build-strategies-plugin with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Deprecated
@Override
public boolean isAutomaticBuild(@NonNull SCMSource source, @NonNull SCMHead head, @NonNull SCMRevision currRevision,
                                @CheckForNull SCMRevision prevRevision) {
    return isAutomaticBuild(source, head, currRevision, prevRevision, new LogTaskListener(Logger.getLogger(getClass().getName()), Level.INFO));
}
 
Example #23
Source File: TagBuildStrategyImpl.java    From basic-branch-build-strategies-plugin with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Deprecated
@Override
public boolean isAutomaticBuild(@NonNull SCMSource source, @NonNull SCMHead head, @NonNull SCMRevision currRevision,
                                @CheckForNull SCMRevision prevRevision, @NonNull  TaskListener taskListener) {
    return isAutomaticBuild(source,head, currRevision, prevRevision, prevRevision, taskListener);
}
 
Example #24
Source File: TagBuildStrategyImpl.java    From basic-branch-build-strategies-plugin with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Deprecated
@Override
public boolean isAutomaticBuild(@NonNull SCMSource source, @NonNull SCMHead head, @NonNull SCMRevision currRevision,
                                @CheckForNull SCMRevision prevRevision) {
    return isAutomaticBuild(source, head, currRevision, prevRevision, new LogTaskListener(Logger.getLogger(getClass().getName()), Level.INFO));
}
 
Example #25
Source File: GitHubBranchBuildStrategy.java    From github-integration-plugin with MIT License 5 votes vote down vote up
@Override
public boolean isAutomaticBuild(SCMSource source, SCMHead head, SCMRevision revision) {
    if (!(revision instanceof GitHubSCMRevision)) {
        return false;
    }
    GitHubSCMRevision gr = (GitHubSCMRevision) revision;
    if (gr.getCause() == null) {
        return false;
    }
    return !gr.getCause().isSkip();
}
 
Example #26
Source File: NamedBranchBuildStrategyImpl.java    From basic-branch-build-strategies-plugin with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Deprecated
@Override
public boolean isAutomaticBuild(@NonNull SCMSource source, @NonNull SCMHead head, @NonNull SCMRevision currRevision,
                                @CheckForNull SCMRevision prevRevision, @NonNull TaskListener taskListener) {
    return isAutomaticBuild(source,head, currRevision, prevRevision, prevRevision, taskListener);
}
 
Example #27
Source File: NamedBranchBuildStrategyImpl.java    From basic-branch-build-strategies-plugin with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Deprecated
@Override
public boolean isAutomaticBuild(@NonNull SCMSource source, @NonNull SCMHead head, @NonNull SCMRevision currRevision,
                                @CheckForNull SCMRevision prevRevision) {
    return isAutomaticBuild(source, head, currRevision, prevRevision, new LogTaskListener(Logger.getLogger(getClass().getName()), Level.INFO));
}
 
Example #28
Source File: SkipInitialBuildOnFirstBranchIndexing.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 (lastSeenRevision != null) {
        return true;
    }
    return false;
}
 
Example #29
Source File: AbstractGiteaSCMHeadEvent.java    From gitea-plugin with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@NonNull
@Override
public Map<SCMHead, SCMRevision> heads(@NonNull SCMSource source) {
    if (source instanceof GiteaSCMSource) {
        // check the owner, we don't care about the event if the owner isn't a match
        GiteaSCMSource src = (GiteaSCMSource) source;
        return StringUtils.equalsIgnoreCase(getPayload().getRepository().getOwner().getUsername(), src.getRepoOwner())
                && StringUtils.equalsIgnoreCase(getPayload().getRepository().getName(), src.getRepository())
                && GiteaServers.isEventFor(src.getServerUrl(), getPayload().getRepository().getHtmlUrl())
                ? headsFor(src)
                : Collections.<SCMHead, SCMRevision>emptyMap();
    }
    return Collections.emptyMap();
}
 
Example #30
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);
}