Search in sources :

Example 1 with GitHubSCMSourceBuilder

use of org.jenkinsci.plugins.github_branch_source.GitHubSCMSourceBuilder in project blueocean-plugin by jenkinsci.

the class GithubPipelineCreateRequest method createSource.

@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(// take all branches
    new BranchDiscoveryTrait(true, true)).withTrait(new ForkPullRequestDiscoveryTrait(strategies, new ForkPullRequestDiscoveryTrait.TrustPermission())).withTrait(new OriginPullRequestDiscoveryTrait(strategies)).withTrait(new CleanBeforeCheckoutTrait()).withTrait(new CleanAfterCheckoutTrait()).withTrait(new LocalBranchTrait()).build();
}
Also used : ForkPullRequestDiscoveryTrait(org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait) OriginPullRequestDiscoveryTrait(org.jenkinsci.plugins.github_branch_source.OriginPullRequestDiscoveryTrait) CleanAfterCheckoutTrait(jenkins.plugins.git.traits.CleanAfterCheckoutTrait) CleanBeforeCheckoutTrait(jenkins.plugins.git.traits.CleanBeforeCheckoutTrait) GitHubSCMSourceBuilder(org.jenkinsci.plugins.github_branch_source.GitHubSCMSourceBuilder) LocalBranchTrait(jenkins.plugins.git.traits.LocalBranchTrait) ChangeRequestCheckoutStrategy(jenkins.scm.api.mixin.ChangeRequestCheckoutStrategy) BranchDiscoveryTrait(org.jenkinsci.plugins.github_branch_source.BranchDiscoveryTrait) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 CleanAfterCheckoutTrait (jenkins.plugins.git.traits.CleanAfterCheckoutTrait)1 CleanBeforeCheckoutTrait (jenkins.plugins.git.traits.CleanBeforeCheckoutTrait)1 LocalBranchTrait (jenkins.plugins.git.traits.LocalBranchTrait)1 ChangeRequestCheckoutStrategy (jenkins.scm.api.mixin.ChangeRequestCheckoutStrategy)1 BranchDiscoveryTrait (org.jenkinsci.plugins.github_branch_source.BranchDiscoveryTrait)1 ForkPullRequestDiscoveryTrait (org.jenkinsci.plugins.github_branch_source.ForkPullRequestDiscoveryTrait)1 GitHubSCMSourceBuilder (org.jenkinsci.plugins.github_branch_source.GitHubSCMSourceBuilder)1 OriginPullRequestDiscoveryTrait (org.jenkinsci.plugins.github_branch_source.OriginPullRequestDiscoveryTrait)1