use of jenkins.scm.api.mixin.ChangeRequestCheckoutStrategy 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();
}
use of jenkins.scm.api.mixin.ChangeRequestCheckoutStrategy in project blueocean-plugin by jenkinsci.
the class BitbucketPipelineCreateRequest method createSource.
@Override
protected SCMSource createSource(@Nonnull MultiBranchProject project, @Nonnull BlueScmConfig scmConfig) {
/* scmConfig.uri presence is already validated in {@link #validate} but lets check just in case */
if (StringUtils.isBlank(scmConfig.getUri())) {
throw new ServiceException.BadRequestException("scmConfig.uri must be present");
}
Set<ChangeRequestCheckoutStrategy> strategies = new HashSet<>();
strategies.add(ChangeRequestCheckoutStrategy.MERGE);
BitbucketSCMSource bitbucketSCMSource = new BitbucketSCMSourceBuilder(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.TrustTeamForks())).withTrait(new OriginPullRequestDiscoveryTrait(strategies)).withTrait(new CleanBeforeCheckoutTrait()).withTrait(new CleanAfterCheckoutTrait()).withTrait(new LocalBranchTrait()).build();
// Setup Jenkins root url, if not set bitbucket cloud notification will fail
JenkinsLocationConfiguration jenkinsLocationConfiguration = JenkinsLocationConfiguration.get();
if (jenkinsLocationConfiguration != null) {
String url = jenkinsLocationConfiguration.getUrl();
if (url == null) {
url = Jenkins.getInstance().getRootUrl();
if (url != null) {
jenkinsLocationConfiguration.setUrl(url);
}
}
}
return bitbucketSCMSource;
}
Aggregations