diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketGitSCMBuilder.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketGitSCMBuilder.java index c54368107..39f5ed0c5 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketGitSCMBuilder.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketGitSCMBuilder.java @@ -29,9 +29,9 @@ import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepository; import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepositoryProtocol; import com.cloudbees.jenkins.plugins.bitbucket.api.PullRequestBranchType; +import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpointProvider; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.AbstractBitbucketEndpoint; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketServerEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketServerEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.impl.extension.FallbackToOtherRepositoryGitSCMExtension; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.BitbucketApiUtils; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.BitbucketCredentials; @@ -112,11 +112,10 @@ public BitbucketGitSCMBuilder(@NonNull BitbucketSCMSource scmSource, @NonNull SC this.scmSource = scmSource; String serverURL = scmSource.getServerUrl(); - AbstractBitbucketEndpoint endpoint = (AbstractBitbucketEndpoint) BitbucketEndpointProvider - .lookupEndpoint(serverURL) + BitbucketEndpoint endpoint = BitbucketEndpointProvider.lookupEndpoint(serverURL) .orElse(new BitbucketServerEndpoint(null, serverURL, false, null, false, null)); - String repositoryURL = endpoint.getRepositoryUrl(scmSource.getRepoOwner(), scmSource.getRepository()); + String repositoryURL = endpoint.getRepositoryURL(scmSource.getRepoOwner(), scmSource.getRepository()); if (BitbucketApiUtils.isCloud(endpoint.getServerURL())) { withBrowser(new BitbucketWeb(repositoryURL)); } else { diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigator.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigator.java index 3b6c18ff4..55aa52557 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigator.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigator.java @@ -31,10 +31,9 @@ import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketTeam; import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpointProvider; import com.cloudbees.jenkins.plugins.bitbucket.client.repository.UserRoleInRepository; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.AbstractBitbucketEndpoint; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketServerEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.impl.avatars.BitbucketTeamAvatarMetadataAction; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketServerEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.BitbucketApiUtils; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.BitbucketCredentials; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.MirrorListSupplier; @@ -232,7 +231,7 @@ public void setServerUrl(@CheckForNull String serverUrl) { @Deprecated(since = "936.4.0", forRemoval = true) @NonNull public String getEndpointJenkinsRootUrl() { - return AbstractBitbucketEndpoint.getEndpointJenkinsRootUrl(serverUrl); + return BitbucketEndpointProvider.lookupEndpointJenkinsRootURL(serverUrl); } @NonNull diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource.java index 7c18a86af..4e7c2f309 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource.java @@ -40,12 +40,11 @@ import com.cloudbees.jenkins.plugins.bitbucket.api.PullRequestBranchType; import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpointProvider; import com.cloudbees.jenkins.plugins.bitbucket.client.repository.UserRoleInRepository; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.AbstractBitbucketEndpoint; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketEndpointConfiguration; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketServerEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.hooks.HasPullRequests; import com.cloudbees.jenkins.plugins.bitbucket.impl.avatars.BitbucketRepoAvatarMetadataAction; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketServerEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.impl.extension.BitbucketEnvVarExtension; import com.cloudbees.jenkins.plugins.bitbucket.impl.extension.GitClientAuthenticatorExtension; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.BitbucketApiUtils; @@ -295,9 +294,10 @@ public void setServerUrl(@CheckForNull String serverUrl) { } } + @Deprecated(since = "936.4.0", forRemoval = true) @NonNull public String getEndpointJenkinsRootURL() { - return AbstractBitbucketEndpoint.getEndpointJenkinsRootUrl(serverUrl); + return BitbucketEndpointProvider.lookupEndpointJenkinsRootURL(serverUrl); } @Override diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/api/BitbucketAuthenticator.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/api/BitbucketAuthenticator.java index a83205603..57778b19a 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/api/BitbucketAuthenticator.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/api/BitbucketAuthenticator.java @@ -23,7 +23,7 @@ */ package com.cloudbees.jenkins.plugins.bitbucket.api; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.BitbucketApiUtils; import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials; import hudson.plugins.git.GitSCM; diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/api/endpoint/BitbucketEndpoint.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/api/endpoint/BitbucketEndpoint.java index a0fe8f6cd..b8db73004 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/api/endpoint/BitbucketEndpoint.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/api/endpoint/BitbucketEndpoint.java @@ -103,7 +103,7 @@ public interface BitbucketEndpoint extends Describable { * * @return the verbatim setting provided by endpoint configuration */ - @CheckForNull + @NonNull String getEndpointJenkinsRootURL(); boolean isEnableHookSignature(); diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/api/endpoint/BitbucketEndpointProvider.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/api/endpoint/BitbucketEndpointProvider.java index 4bf058508..fb6027934 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/api/endpoint/BitbucketEndpointProvider.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/api/endpoint/BitbucketEndpointProvider.java @@ -23,14 +23,15 @@ */ package com.cloudbees.jenkins.plugins.bitbucket.api.endpoint; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketEndpointConfiguration; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketServerEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketServerEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.BitbucketApiUtils; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.URLUtils; import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.Nullable; +import hudson.Util; import hudson.util.ListBoxModel; import java.util.Collection; import java.util.List; @@ -38,6 +39,7 @@ import java.util.Optional; import java.util.function.UnaryOperator; import org.apache.commons.lang3.StringUtils; +import org.jenkinsci.plugins.displayurlapi.DisplayURLProvider; /** * A provider of {@link BitbucketEndpoint}s @@ -94,6 +96,21 @@ public static Optional lookupEndpoint(@CheckFor .findFirst(); } + /** + * Jenkins Server Root URL to be used by the Bitbucket endpoint that matches + * the given serverURL. The global setting from Jenkins.get().getRootUrl() + * will be used if this field is null or equals an empty string. + * + * @param serverURL the server url to check. + * @return the verbatim setting provided by endpoint configuration + */ + @NonNull + public static String lookupEndpointJenkinsRootURL(@CheckForNull String serverURL) { + return lookupEndpoint(serverURL) + .map(BitbucketEndpoint::getEndpointJenkinsRootURL) + .orElse(Util.ensureEndsWith(URLUtils.normalizeURL(Util.fixEmptyAndTrim(DisplayURLProvider.get().getRoot())), "/")); + } + /** * Checks to see if the supplied server URL is defined in the global * configuration. diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/client/BitbucketCloudApiFactory.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/client/BitbucketCloudApiFactory.java index b51c6d25c..45cf2c8f0 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/client/BitbucketCloudApiFactory.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/client/BitbucketCloudApiFactory.java @@ -27,7 +27,7 @@ import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketApiFactory; import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketAuthenticator; import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpointProvider; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.Nullable; diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpointDescriptor.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpointDescriptor.java deleted file mode 100644 index fec635564..000000000 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpointDescriptor.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2017, CloudBees, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package com.cloudbees.jenkins.plugins.bitbucket.endpoints; - -import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpointDescriptor; -import hudson.model.Descriptor; - -/** - * {@link Descriptor} base class for {@link AbstractBitbucketEndpoint} subclasses. - * - * @since 2.2.0 - */ -@Deprecated(since = "936.4.0") -public abstract class AbstractBitbucketEndpointDescriptor extends BitbucketEndpointDescriptor { -} diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketEndpointConfiguration.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketEndpointConfiguration.java index 48d4ef98a..9a773dee4 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketEndpointConfiguration.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketEndpointConfiguration.java @@ -25,6 +25,8 @@ import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpointProvider; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketServerEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.BitbucketApiUtils; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.URLUtils; import edu.umd.cs.findbugs.annotations.CheckForNull; @@ -32,9 +34,12 @@ import hudson.Extension; import hudson.ExtensionList; import hudson.Util; +import hudson.XmlFile; import hudson.security.ACL; import hudson.security.Permission; import hudson.util.ListBoxModel; +import hudson.util.XStream2; +import java.io.File; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; @@ -73,6 +78,17 @@ public BitbucketEndpointConfiguration() { load(); } + // TODO remove within a year + @Restricted(NoExternalUse.class) + @Override + public XmlFile getConfigFile() { + File cfgFile = new File(Jenkins.get().getRootDir(), getId() + ".xml"); + XStream2 xs = new XStream2(XStream2.getDefaultDriver()); + xs.alias("com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint", BitbucketCloudEndpoint.class); + xs.alias("com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketServerEndpoint", BitbucketServerEndpoint.class); + return new XmlFile(xs, cfgFile); + } + /** * Gets the {@link BitbucketEndpointConfiguration} singleton. * @@ -156,9 +172,9 @@ public boolean configure(StaplerRequest2 req, JSONObject json) throws FormExcept * @return the list of endpoints */ @NonNull - public List getEndpoints() { + public List getEndpoints() { // make a local copy so if changes in meanwhile you do not get NPE - List/**/ localEndpoints = this.endpoints; + List localEndpoints = this.endpoints; return CollectionUtils.isEmpty(localEndpoints) ? List.of(new BitbucketCloudEndpoint()) : Collections.unmodifiableList(localEndpoints); diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/filesystem/BitbucketSCMFileSystem.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/filesystem/BitbucketSCMFileSystem.java index 428b63555..d9b8a8805 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/filesystem/BitbucketSCMFileSystem.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/filesystem/BitbucketSCMFileSystem.java @@ -31,7 +31,7 @@ import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketApiFactory; import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketAuthenticator; import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketCommit; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketServerEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketServerEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.BitbucketApiUtils; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.DateUtils; import com.cloudbees.jenkins.plugins.bitbucket.server.BitbucketServerVersion; diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/BitbucketSCMSourcePushHookReceiver.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/BitbucketSCMSourcePushHookReceiver.java index 5bb85421c..68b012fd3 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/BitbucketSCMSourcePushHookReceiver.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/BitbucketSCMSourcePushHookReceiver.java @@ -25,7 +25,7 @@ import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpointProvider; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.Nullable; diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/WebhookAutoRegisterListener.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/WebhookAutoRegisterListener.java index 10d45025e..fd79c0943 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/WebhookAutoRegisterListener.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/WebhookAutoRegisterListener.java @@ -40,7 +40,6 @@ import hudson.util.DaemonThreadFactory; import hudson.util.NamingThreadFactory; import java.io.IOException; -import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -133,7 +132,7 @@ private synchronized void registerHooks(SCMSourceOwner owner) throws IOException return; } for (BitbucketSCMSource source : sources) { - String rootUrl = source.getEndpointJenkinsRootURL(); + String rootUrl = BitbucketEndpointProvider.lookupEndpointJenkinsRootURL(source.getServerUrl()); if (!rootUrl.startsWith("http://localhost") && !rootUrl.startsWith("http://unconfigured-jenkins-location")) { registerHook(source); } else { @@ -161,13 +160,13 @@ private synchronized void registerHooks(SCMSourceOwner owner) throws IOException } private void registerHook(BitbucketSCMSource source) throws IOException { - BitbucketApi bitbucket = bitbucketApiFor(source); + BitbucketApi bitbucket = getClientBySource(source); if (bitbucket == null) { return; } BitbucketWebHook existingHook; - String hookReceiverURL = source.getEndpointJenkinsRootURL() + BitbucketSCMSourcePushHookReceiver.FULL_PATH; + String hookReceiverURL = getHookReceiverURL(source.getServerUrl()); // Check for all hooks pointing to us existingHook = bitbucket.getWebHooks().stream() .filter(hook -> hook.getUrl() != null) @@ -187,16 +186,20 @@ private void registerHook(BitbucketSCMSource source) throws IOException { } } + private String getHookReceiverURL(String endpointURL) { + return BitbucketEndpointProvider.lookupEndpointJenkinsRootURL(endpointURL) + BitbucketSCMSourcePushHookReceiver.FULL_PATH; + } + private void removeHooks(SCMSourceOwner owner) throws IOException { List sources = getBitbucketSCMSources(owner); for (BitbucketSCMSource source : sources) { - BitbucketApi bitbucket = bitbucketApiFor(source); + BitbucketApi bitbucket = getClientBySource(source); if (bitbucket != null) { List existent = bitbucket.getWebHooks(); BitbucketWebHook hook = null; for (BitbucketWebHook h : existent) { // Check if there is a hook pointing to us - if (h.getUrl().startsWith(source.getEndpointJenkinsRootURL() + BitbucketSCMSourcePushHookReceiver.FULL_PATH)) { + if (h.getUrl().startsWith(getHookReceiverURL(source.getServerUrl()))) { hook = h; break; } @@ -214,7 +217,7 @@ private void removeHooks(SCMSourceOwner owner) throws IOException { } @CheckForNull - private BitbucketApi bitbucketApiFor(@NonNull BitbucketSCMSource source) { + private BitbucketApi getClientBySource(@NonNull BitbucketSCMSource source) { switch (new BitbucketSCMSourceContext(null, SCMHeadObserver.none()) .withTraits(source.getTraits()) .webhookRegistration()) { @@ -257,13 +260,10 @@ private boolean isUsedSomewhereElse(SCMSourceOwner owner, String repoOwner, Stri } private List getBitbucketSCMSources(SCMSourceOwner owner) { - List sources = new ArrayList<>(); - for (SCMSource source : owner.getSCMSources()) { - if (source instanceof BitbucketSCMSource) { - sources.add((BitbucketSCMSource) source); - } - } - return sources; + return owner.getSCMSources().stream() + .filter(BitbucketSCMSource.class::isInstance) + .map(BitbucketSCMSource.class::cast) + .toList(); } /** diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/WebhookConfiguration.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/WebhookConfiguration.java index b8a3c521c..1be0da7e1 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/WebhookConfiguration.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/WebhookConfiguration.java @@ -28,7 +28,7 @@ import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpointProvider; import com.cloudbees.jenkins.plugins.bitbucket.client.repository.BitbucketRepositoryHook; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketServerEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketServerEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.BitbucketApiUtils; import com.cloudbees.jenkins.plugins.bitbucket.server.client.repository.BitbucketServerWebhook; import com.cloudbees.jenkins.plugins.bitbucket.server.client.repository.NativeBitbucketServerWebhook; @@ -147,7 +147,7 @@ boolean updateHook(BitbucketWebHook hook, BitbucketSCMSource owner) { } } else if (hook instanceof NativeBitbucketServerWebhook serverHook) { String serverURL = owner.getServerUrl(); - String url = getNativeServerWebhookUrl(serverURL, owner.getEndpointJenkinsRootURL()); + String url = getNativeServerWebhookUrl(serverURL, BitbucketEndpointProvider.lookupEndpointJenkinsRootURL(owner.getServerUrl())); if (!url.equals(serverHook.getUrl())) { serverHook.setUrl(url); @@ -176,7 +176,7 @@ boolean updateHook(BitbucketWebHook hook, BitbucketSCMSource owner) { public BitbucketWebHook getHook(BitbucketSCMSource owner) { final String serverUrl = owner.getServerUrl(); - final String rootUrl = owner.getEndpointJenkinsRootURL(); + final String rootUrl = BitbucketEndpointProvider.lookupEndpointJenkinsRootURL(owner.getServerUrl()); final String signatureSecret = getSecret(owner.getServerUrl()); if (BitbucketApiUtils.isCloud(serverUrl)) { diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpoint.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/AbstractBitbucketEndpoint.java similarity index 87% rename from src/main/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpoint.java rename to src/main/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/AbstractBitbucketEndpoint.java index dc84d3161..4a42511ff 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpoint.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/AbstractBitbucketEndpoint.java @@ -21,11 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package com.cloudbees.jenkins.plugins.bitbucket.endpoints; +package com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint; import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketAuthenticator; import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpoint; -import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpointProvider; +import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpointDescriptor; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.BitbucketCredentials; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.URLUtils; import com.cloudbees.plugins.credentials.common.StandardCredentials; @@ -112,7 +112,7 @@ public abstract class AbstractBitbucketEndpoint implements BitbucketEndpoint { * @return the normalized URL ending with a slash */ @NonNull - static String normalizeJenkinsRootUrl(String rootUrl) { + static String normalizeJenkinsRootURL(String rootUrl) { // This routine is not really BitbucketEndpointConfiguration // specific, it just works on strings with some defaults: return Util.ensureEndsWith(URLUtils.normalizeURL(fixEmptyAndTrim(rootUrl)), "/"); @@ -131,9 +131,21 @@ public String getBitbucketJenkinsRootUrl() { return bitbucketJenkinsRootUrl; } + @NonNull @Override public String getEndpointJenkinsRootURL() { - return getBitbucketJenkinsRootUrl(); + // If this instance of Bitbucket connection has a custom root URL + // configured to have this Jenkins server known by (e.g. when a + // private network has different names preferable for different + // clients), return this custom string. Otherwise use global one. + // Note: do not pre-initialize to the global value, so it can be + // reconfigured on the fly. + + String endpointURL = getBitbucketJenkinsRootUrl(); + if (endpointURL == null) { + endpointURL = DisplayURLProvider.get().getRoot(); + } + return normalizeJenkinsRootURL(endpointURL); } @NonNull @@ -145,7 +157,7 @@ public String getRepositoryURL(@NonNull String repoOwner, @NonNull String repoSl @DataBoundSetter public void setBitbucketJenkinsRootUrl(String bitbucketJenkinsRootUrl) { if (manageHooks) { - this.bitbucketJenkinsRootUrl = normalizeJenkinsRootUrl(bitbucketJenkinsRootUrl); + this.bitbucketJenkinsRootUrl = normalizeJenkinsRootURL(bitbucketJenkinsRootUrl); } else { this.bitbucketJenkinsRootUrl = null; } @@ -182,41 +194,6 @@ public String getEndpointJenkinsRootUrl() { } } - /** - * Look up in the current endpoint configurations if one exists for the - * serverUrl, and return its normalized endpointJenkinsRootUrl value, - * or the normalized global default Jenkins Root URL if nothing was found - * or if the setting is an empty string; empty string if there was an error - * finding the global default Jenkins Root URL value (e.g. core not started). - * This is the routine intended for external consumption when one needs a - * Jenkins Root URL to use for webhook configuration. - * - * @param serverURL Bitbucket Server URL for the endpoint config - * - * @return the normalized custom or default Jenkins Root URL value - */ - @NonNull - public static String getEndpointJenkinsRootUrl(String serverURL) { - // If this instance of Bitbucket connection has a custom root URL - // configured to have this Jenkins server known by (e.g. when a - // private network has different names preferable for different - // clients), return this custom string. Otherwise use global one. - // Note: do not pre-initialize to the global value, so it can be - // reconfigured on the fly. - - String endpointURL = null; - BitbucketEndpoint endpoint = BitbucketEndpointProvider - .lookupEndpoint(serverURL) - .orElse(null); - if (endpoint != null) { - endpointURL = endpoint.getEndpointJenkinsRootURL(); - } - if (endpointURL == null) { - endpointURL = DisplayURLProvider.get().getRoot(); - } - return endpointURL; - } - /** * The user facing URL of the specified repository. * @@ -286,7 +263,7 @@ public BitbucketAuthenticator authenticator() { * {@inheritDoc} */ @Override - public AbstractBitbucketEndpointDescriptor getDescriptor() { - return (AbstractBitbucketEndpointDescriptor) Jenkins.get().getDescriptorOrDie(getClass()); + public BitbucketEndpointDescriptor getDescriptor() { + return (BitbucketEndpointDescriptor) Jenkins.get().getDescriptorOrDie(getClass()); } } diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketCloudEndpoint.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketCloudEndpoint.java similarity index 96% rename from src/main/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketCloudEndpoint.java rename to src/main/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketCloudEndpoint.java index ef0610f83..78934ab1b 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketCloudEndpoint.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketCloudEndpoint.java @@ -21,8 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package com.cloudbees.jenkins.plugins.bitbucket.endpoints; +package com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint; +import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpointDescriptor; import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.EndpointType; import com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient; import com.cloudbees.plugins.credentials.common.StandardCredentials; @@ -162,7 +163,7 @@ public EndpointType getType() { * Our descriptor. */ @Extension - public static class DescriptorImpl extends AbstractBitbucketEndpointDescriptor { + public static class DescriptorImpl extends BitbucketEndpointDescriptor { /** * {@inheritDoc} */ diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketServerEndpoint.java similarity index 97% rename from src/main/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint.java rename to src/main/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketServerEndpoint.java index 6e7fe7073..03998889a 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketServerEndpoint.java @@ -21,8 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package com.cloudbees.jenkins.plugins.bitbucket.endpoints; +package com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint; +import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpointDescriptor; import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpointProvider; import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.EndpointType; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.URLUtils; @@ -121,7 +122,7 @@ public static BitbucketServerVersion findServerVersion(String serverURL) { * Default constructor. * @param serverURL */ - BitbucketServerEndpoint(@NonNull String serverURL) { + public BitbucketServerEndpoint(@NonNull String serverURL) { this(null, serverURL, false, null, false, null); } @@ -266,7 +267,7 @@ public void setWebhookImplementation(@NonNull BitbucketServerWebhookImplementati * Our descriptor. */ @Extension - public static class DescriptorImpl extends AbstractBitbucketEndpointDescriptor { + public static class DescriptorImpl extends BitbucketEndpointDescriptor { @Restricted(NoExternalUse.class) // stapler @RequirePOST diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/server/client/BitbucketServerAPIClient.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/server/client/BitbucketServerAPIClient.java index 28e97b9ef..5f462dd7b 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/server/client/BitbucketServerAPIClient.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/server/client/BitbucketServerAPIClient.java @@ -37,12 +37,12 @@ import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketWebHook; import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpointProvider; import com.cloudbees.jenkins.plugins.bitbucket.client.repository.UserRoleInRepository; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketServerEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.filesystem.BitbucketSCMFile; import com.cloudbees.jenkins.plugins.bitbucket.impl.client.AbstractBitbucketApi; import com.cloudbees.jenkins.plugins.bitbucket.impl.credentials.BitbucketAccessTokenAuthenticator; import com.cloudbees.jenkins.plugins.bitbucket.impl.credentials.BitbucketClientCertificateAuthenticator; import com.cloudbees.jenkins.plugins.bitbucket.impl.credentials.BitbucketUsernamePasswordAuthenticator; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketServerEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.BitbucketApiUtils; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.JsonParser; import com.cloudbees.jenkins.plugins.bitbucket.server.BitbucketServerVersion; diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/server/client/BitbucketServerApiFactory.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/server/client/BitbucketServerApiFactory.java index c4dd6f338..23a98353a 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/server/client/BitbucketServerApiFactory.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/server/client/BitbucketServerApiFactory.java @@ -26,7 +26,7 @@ import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketApi; import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketApiFactory; import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketAuthenticator; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.Nullable; diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpoint/config.jelly b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/AbstractBitbucketEndpoint/config.jelly similarity index 100% rename from src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpoint/config.jelly rename to src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/AbstractBitbucketEndpoint/config.jelly diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpoint/help-bitbucketJenkinsRootUrl.html b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/AbstractBitbucketEndpoint/help-bitbucketJenkinsRootUrl.html similarity index 100% rename from src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpoint/help-bitbucketJenkinsRootUrl.html rename to src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/AbstractBitbucketEndpoint/help-bitbucketJenkinsRootUrl.html diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpoint/help-credentialsId.html b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/AbstractBitbucketEndpoint/help-credentialsId.html similarity index 100% rename from src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpoint/help-credentialsId.html rename to src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/AbstractBitbucketEndpoint/help-credentialsId.html diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpoint/help-enableHookSignature.html b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/AbstractBitbucketEndpoint/help-enableHookSignature.html similarity index 100% rename from src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpoint/help-enableHookSignature.html rename to src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/AbstractBitbucketEndpoint/help-enableHookSignature.html diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpoint/help-hookSignatureCredentialsId.html b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/AbstractBitbucketEndpoint/help-hookSignatureCredentialsId.html similarity index 100% rename from src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpoint/help-hookSignatureCredentialsId.html rename to src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/AbstractBitbucketEndpoint/help-hookSignatureCredentialsId.html diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpoint/help-manageHooks.html b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/AbstractBitbucketEndpoint/help-manageHooks.html similarity index 100% rename from src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpoint/help-manageHooks.html rename to src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/AbstractBitbucketEndpoint/help-manageHooks.html diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketCloudEndpoint/config-detail.jelly b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketCloudEndpoint/config-detail.jelly similarity index 100% rename from src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketCloudEndpoint/config-detail.jelly rename to src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketCloudEndpoint/config-detail.jelly diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/config-detail.jelly b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketServerEndpoint/config-detail.jelly similarity index 100% rename from src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/config-detail.jelly rename to src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketServerEndpoint/config-detail.jelly diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/help-callCanMerge.html b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketServerEndpoint/help-callCanMerge.html similarity index 100% rename from src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/help-callCanMerge.html rename to src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketServerEndpoint/help-callCanMerge.html diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/help-callChanges.html b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketServerEndpoint/help-callChanges.html similarity index 100% rename from src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/help-callChanges.html rename to src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketServerEndpoint/help-callChanges.html diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/help-displayName.html b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketServerEndpoint/help-displayName.html similarity index 100% rename from src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/help-displayName.html rename to src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketServerEndpoint/help-displayName.html diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/help-serverUrl.html b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketServerEndpoint/help-serverUrl.html similarity index 100% rename from src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/help-serverUrl.html rename to src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketServerEndpoint/help-serverUrl.html diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/help-serverVersion.html b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketServerEndpoint/help-serverVersion.html similarity index 100% rename from src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/help-serverVersion.html rename to src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketServerEndpoint/help-serverVersion.html diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/help-webhookImplementation.html b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketServerEndpoint/help-webhookImplementation.html similarity index 100% rename from src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/help-webhookImplementation.html rename to src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketServerEndpoint/help-webhookImplementation.html diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/manage-hooks-detail.jelly b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketServerEndpoint/manage-hooks-detail.jelly similarity index 100% rename from src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/manage-hooks-detail.jelly rename to src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketServerEndpoint/manage-hooks-detail.jelly diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/Messages.properties b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/Messages.properties similarity index 100% rename from src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/Messages.properties rename to src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/Messages.properties diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketAuthenticatorTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketAuthenticatorTest.java index 741790582..64ded8be0 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketAuthenticatorTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketAuthenticatorTest.java @@ -24,11 +24,11 @@ package com.cloudbees.jenkins.plugins.bitbucket; import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketAuthenticator; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.impl.credentials.BitbucketAccessTokenAuthenticator; import com.cloudbees.jenkins.plugins.bitbucket.impl.credentials.BitbucketClientCertificateAuthenticator; import com.cloudbees.jenkins.plugins.bitbucket.impl.credentials.BitbucketOAuthAuthenticator; import com.cloudbees.jenkins.plugins.bitbucket.impl.credentials.BitbucketUsernamePasswordAuthenticator; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; import com.cloudbees.plugins.credentials.Credentials; import com.cloudbees.plugins.credentials.CredentialsMatchers; import com.cloudbees.plugins.credentials.CredentialsScope; diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketGitSCMBuilderTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketGitSCMBuilderTest.java index 5dcc27fb9..717c1fa49 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketGitSCMBuilderTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketGitSCMBuilderTest.java @@ -28,7 +28,7 @@ import com.cloudbees.jenkins.plugins.bitbucket.client.branch.BitbucketCloudAuthor; import com.cloudbees.jenkins.plugins.bitbucket.client.branch.BitbucketCloudCommit; import com.cloudbees.jenkins.plugins.bitbucket.client.branch.BitbucketCloudCommit.Parent; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.impl.extension.FallbackToOtherRepositoryGitSCMExtension; import com.cloudbees.jenkins.plugins.bitbucket.server.client.branch.BitbucketServerCommit; import com.cloudbees.jenkins.plugins.bitbucket.trait.SSHCheckoutTrait; diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketGitSCMRevisionTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketGitSCMRevisionTest.java index eb19295c9..0e9251740 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketGitSCMRevisionTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketGitSCMRevisionTest.java @@ -23,7 +23,7 @@ */ package com.cloudbees.jenkins.plugins.bitbucket; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.trait.BranchDiscoveryTrait; import com.cloudbees.jenkins.plugins.bitbucket.trait.ForkPullRequestDiscoveryTrait; import com.cloudbees.jenkins.plugins.bitbucket.trait.ForkPullRequestDiscoveryTrait.TrustTeamForks; diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigatorTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigatorTest.java index cc4285d16..6ba0d4cf7 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigatorTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMNavigatorTest.java @@ -23,7 +23,7 @@ */ package com.cloudbees.jenkins.plugins.bitbucket; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.trait.BranchDiscoveryTrait; import com.cloudbees.jenkins.plugins.bitbucket.trait.WebhookRegistrationTrait; import java.util.Arrays; diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSourceRetrieveTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSourceRetrieveTest.java index 43745a8a0..b51397c83 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSourceRetrieveTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSourceRetrieveTest.java @@ -33,9 +33,9 @@ import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepository; import com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient; import com.cloudbees.jenkins.plugins.bitbucket.client.branch.BitbucketCloudBranch; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.hooks.HasPullRequests; import com.cloudbees.jenkins.plugins.bitbucket.impl.BitbucketPlugin; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient; import com.cloudbees.jenkins.plugins.bitbucket.server.client.branch.BitbucketServerBranch; import com.cloudbees.jenkins.plugins.bitbucket.trait.ForkPullRequestDiscoveryTrait; diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSourceTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSourceTest.java index 41c2c74c9..85d2bbb43 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSourceTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSourceTest.java @@ -27,9 +27,10 @@ import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketIntegrationClientFactory; import com.cloudbees.jenkins.plugins.bitbucket.client.pullrequest.BitbucketCloudPullRequestCommit; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketEndpointConfiguration; +import com.cloudbees.jenkins.plugins.bitbucket.impl.BitbucketPlugin; import com.cloudbees.jenkins.plugins.bitbucket.impl.avatars.BitbucketRepoAvatarMetadataAction; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.impl.extension.BitbucketEnvVarExtension; import com.cloudbees.jenkins.plugins.bitbucket.trait.BranchDiscoveryTrait; import com.cloudbees.jenkins.plugins.bitbucket.trait.ShowBitbucketAvatarTrait; @@ -40,6 +41,7 @@ import com.cloudbees.plugins.credentials.common.StandardUsernameCredentials; import com.cloudbees.plugins.credentials.domains.Domain; import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl; +import com.thoughtworks.xstream.XStream; import hudson.model.TaskListener; import hudson.plugins.git.GitSCM; import hudson.plugins.git.extensions.GitSCMExtension; @@ -81,6 +83,7 @@ class BitbucketSCMSourceTest { @BeforeAll static void init(JenkinsRule rule) { j = rule; + BitbucketPlugin.aliases(); } private String testName; @@ -102,8 +105,9 @@ private BitbucketSCMSource load(String dataSet) { private void loadBEC(String dataSet) { // Note to use original BitbucketSCMSourceTest::getClass() here to get proper paths String path = getClass().getSimpleName() + "/" + BitbucketEndpointConfiguration.class.getSimpleName() + "/" + dataSet + ".xml"; + XStream xs = new BitbucketEndpointConfiguration().getConfigFile().getXStream(); URL url = getClass().getResource(path); - BitbucketEndpointConfiguration bec = (BitbucketEndpointConfiguration) Jenkins.XSTREAM2.fromXML(url); + BitbucketEndpointConfiguration bec = (BitbucketEndpointConfiguration) xs.fromXML(url); for (BitbucketEndpoint abe : bec.getEndpoints()) { if (abe != null) { BitbucketEndpointConfiguration.get().updateEndpoint(abe); @@ -230,7 +234,7 @@ void bitbucketJenkinsRootUrl_emptyDefaulted() throws Exception { // current global root URL (ending with a slash), // meaning "current value at the moment when we ask". JenkinsLocationConfiguration.get().setUrl("http://localjenkins:80"); - assertThat(instance.getEndpointJenkinsRootURL()).isEqualTo("http://localjenkins:80/"); + assertThat(instance.getEndpointJenkinsRootURL()).isEqualTo("http://localjenkins/"); JenkinsLocationConfiguration.get().setUrl("https://ourjenkins.master:8443/ci"); assertThat(instance.getEndpointJenkinsRootURL()).isEqualTo("https://ourjenkins.master:8443/ci/"); diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BranchScanningIntegrationTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BranchScanningIntegrationTest.java index 3e8d26e5e..6b38aec49 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BranchScanningIntegrationTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BranchScanningIntegrationTest.java @@ -24,7 +24,7 @@ package com.cloudbees.jenkins.plugins.bitbucket; import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketEndpointConfiguration; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketServerEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketServerEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.BitbucketCredentials; import com.cloudbees.jenkins.plugins.bitbucket.trait.BranchDiscoveryTrait; import com.cloudbees.jenkins.plugins.bitbucket.trait.ForkPullRequestDiscoveryTrait; diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BranchScanningTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BranchScanningTest.java index 6828bc508..187a62582 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BranchScanningTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BranchScanningTest.java @@ -25,7 +25,7 @@ import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketHref; import com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.trait.BranchDiscoveryTrait; import com.cloudbees.jenkins.plugins.bitbucket.trait.ForkPullRequestDiscoveryTrait; import com.cloudbees.jenkins.plugins.bitbucket.trait.OriginPullRequestDiscoveryTrait; diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/SCMTraitCommitTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/SCMTraitCommitTest.java index 8326b38e9..166222982 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/SCMTraitCommitTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/SCMTraitCommitTest.java @@ -26,7 +26,7 @@ import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketBranch; import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketCommit; import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketPullRequest; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.trait.BranchDiscoveryTrait; import com.cloudbees.jenkins.plugins.bitbucket.trait.ForkPullRequestDiscoveryTrait; import com.cloudbees.jenkins.plugins.bitbucket.trait.OriginPullRequestDiscoveryTrait; diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/Security2033Test.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/Security2033Test.java index 23900e59e..6051fcbbc 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/Security2033Test.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/Security2033Test.java @@ -23,7 +23,7 @@ */ package com.cloudbees.jenkins.plugins.bitbucket; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; import com.cloudbees.plugins.credentials.CredentialsScope; import com.cloudbees.plugins.credentials.SystemCredentialsProvider; import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials; diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/WebhooksAutoregisterTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/WebhooksAutoregisterTest.java index 199e8b155..874f13c48 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/WebhooksAutoregisterTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/WebhooksAutoregisterTest.java @@ -24,9 +24,9 @@ package com.cloudbees.jenkins.plugins.bitbucket; import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketApi; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketEndpointConfiguration; import com.cloudbees.jenkins.plugins.bitbucket.hooks.WebhookAutoRegisterListener; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.trait.WebhookRegistrationTrait; import hudson.model.listeners.ItemListener; import hudson.util.RingBufferLogHandler; diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/client/BitbucketCloudApiClientTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/client/BitbucketCloudApiClientTest.java index 4c738023f..7c1e230c5 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/client/BitbucketCloudApiClientTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/client/BitbucketCloudApiClientTest.java @@ -30,11 +30,11 @@ import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketException; import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketWebHook; import com.cloudbees.jenkins.plugins.bitbucket.client.repository.BitbucketCloudRepository; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.impl.credentials.BitbucketAccessTokenAuthenticator; import com.cloudbees.jenkins.plugins.bitbucket.impl.credentials.BitbucketClientCertificateAuthenticator; import com.cloudbees.jenkins.plugins.bitbucket.impl.credentials.BitbucketOAuthAuthenticator; import com.cloudbees.jenkins.plugins.bitbucket.impl.credentials.BitbucketUsernamePasswordAuthenticator; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.DateUtils; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.JsonParser; import com.cloudbees.jenkins.plugins.bitbucket.test.util.BitbucketTestUtil; diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketEndpointConfigurationTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketEndpointConfigurationTest.java index 263bb9d11..c3a500ae4 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketEndpointConfigurationTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketEndpointConfigurationTest.java @@ -24,6 +24,10 @@ package com.cloudbees.jenkins.plugins.bitbucket.endpoints; import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpointProvider; +import com.cloudbees.jenkins.plugins.bitbucket.impl.BitbucketPlugin; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketServerEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.Messages; import com.cloudbees.jenkins.plugins.bitbucket.server.BitbucketServerVersion; import com.cloudbees.jenkins.plugins.bitbucket.server.BitbucketServerWebhookImplementation; import com.cloudbees.plugins.credentials.Credentials; @@ -70,6 +74,7 @@ class BitbucketEndpointConfigurationTest { @BeforeAll static void init(JenkinsRule rule) { r = rule; + BitbucketPlugin.aliases(); } @AfterEach @@ -90,7 +95,7 @@ void given__newInstance__when__notConfigured__then__cloudPresent() { @Test void given__newInstance__when__configuredWithEmpty__then__cloudPresent() { BitbucketEndpointConfiguration instance = new BitbucketEndpointConfiguration(); - instance.setEndpoints(Collections.emptyList()); + instance.setEndpoints(Collections.emptyList()); assertThat(instance.getEndpoints()).hasOnlyElementsOfType(BitbucketCloudEndpoint.class); } @@ -342,7 +347,7 @@ void given__newInstance__when__removingCloud__then__defaultRestored() { void given__instanceWithCloudAndServers__when__removingServer__then__matchingServerRemoved() { BitbucketEndpointConfiguration instance = new BitbucketEndpointConfiguration(); instance.setEndpoints( - Arrays.asList( + List.of( buildEndpoint(true, "first"), new BitbucketServerEndpoint("Example Inc", "https://bitbucket.example.com/", true, "second"), new BitbucketServerEndpoint("Example Org", "http://example.org:8080/bitbucket/", true, "third") @@ -361,7 +366,7 @@ void given__instanceWithCloudAndServers__when__removingServer__then__matchingSer void given__instanceWithCloudAndServers__when__removingCloud__then__cloudRemoved() { BitbucketEndpointConfiguration instance = new BitbucketEndpointConfiguration(); instance.setEndpoints( - Arrays.asList( + List.of( buildEndpoint(true, "first"), new BitbucketServerEndpoint("Example Inc", "https://bitbucket.example.com/", true, "second"), new BitbucketServerEndpoint("Example Org", "http://example.org:8080/bitbucket/", true, "third") @@ -380,7 +385,7 @@ void given__instanceWithCloudAndServers__when__removingCloud__then__cloudRemoved void given__instanceWithCloudAndServers__when__removingNonExisting__then__noChange() { BitbucketEndpointConfiguration instance = new BitbucketEndpointConfiguration(); instance.setEndpoints( - Arrays.asList( + List.of( buildEndpoint(true, "first"), new BitbucketServerEndpoint("Example Inc", "https://bitbucket.example.com/", true, "second"), new BitbucketServerEndpoint("Example Org", "http://example.org:8080/bitbucket/", true, "third") @@ -399,10 +404,7 @@ void given__instanceWithCloudAndServers__when__removingNonExisting__then__noChan @Test void given__instance__when__onlyOneEndpoint__then__endpointsNotSelectable() { BitbucketEndpointConfiguration instance = new BitbucketEndpointConfiguration(); - instance.setEndpoints( - Collections.singletonList( - new BitbucketServerEndpoint("Example Org", "http://example.org:8080/bitbucket/", true, "dummy") - )); + instance.setEndpoints(List.of(new BitbucketServerEndpoint("Example Org", "http://example.org:8080/bitbucket/", true, "dummy", false, null))); assertThat(instance.isEndpointSelectable()).isFalse(); } @@ -410,7 +412,7 @@ void given__instance__when__onlyOneEndpoint__then__endpointsNotSelectable() { void given__instance__when__multipleEndpoints__then__endpointsSelectable() { BitbucketEndpointConfiguration instance = new BitbucketEndpointConfiguration(); instance.setEndpoints( - Arrays.asList( + List.of( buildEndpoint(true, "first"), new BitbucketServerEndpoint("Example Inc", "https://bitbucket.example.com/", true, "second"), new BitbucketServerEndpoint("Example Org", "http://example.org:8080/bitbucket/", true, "third") @@ -421,7 +423,7 @@ void given__instance__when__multipleEndpoints__then__endpointsSelectable() { @Test void given__instanceWithCloudAndServers__when__findingExistingEndpoint__then__endpointFound() { BitbucketEndpointConfiguration.get().setEndpoints( - Arrays.asList( + List.of( buildEndpoint(true, "first"), new BitbucketServerEndpoint("Example Inc", "https://bitbucket.example.com/", true, "second"), new BitbucketServerEndpoint("Example Org", "http://example.org:8080/bitbucket/", true, "third") @@ -450,7 +452,7 @@ void given__instanceWithCloudAndServers__when__findingExistingEndpoint__then__en @Test void given__instanceWithServers__when__findingNonExistingEndpoint__then__endpointNotFound() { BitbucketEndpointConfiguration.get().setEndpoints( - Arrays.asList( + List.of( new BitbucketServerEndpoint("Example Inc", "https://bitbucket.example.com/", true, "dummy"), new BitbucketServerEndpoint("Example Org", "http://example.org:8080/bitbucket/", true, "dummy") )); @@ -467,7 +469,7 @@ void given__instanceWithServers__when__findingNonExistingEndpoint__then__endpoin @Test void given__instanceWithCloudAndServers__when__findingInvalid__then__endpointNotFound() { BitbucketEndpointConfiguration.get().setEndpoints( - Arrays.asList( + List.of( buildEndpoint(true, "first"), new BitbucketServerEndpoint("Example Inc", "https://bitbucket.example.com/", true, "second"), new BitbucketServerEndpoint("Example Org", "http://example.org:8080/bitbucket/", true, "third") @@ -481,7 +483,7 @@ void given__instanceWithCloudAndServers__when__findingInvalid__then__endpointNot void given__instanceWithCloudAndServers__when__populatingDropBox__then__endpointsListed() { BitbucketEndpointConfiguration instance = new BitbucketEndpointConfiguration(); instance.setEndpoints( - Arrays.asList( + List.of( buildEndpoint(true, "first"), new BitbucketServerEndpoint("Example Inc", "https://bitbucket.example.com/", true, "second"), new BitbucketServerEndpoint("Example Org", "http://example.org:8080/bitbucket/", true, "third") @@ -500,7 +502,7 @@ void given__instanceWithCloudAndServers__when__populatingDropBox__then__endpoint void given__instanceWithCloudAndServers__when__resolvingExistingEndpoint__then__normalizedReturned() { BitbucketEndpointConfiguration instance = new BitbucketEndpointConfiguration(); instance.setEndpoints( - Arrays.asList( + List.of( buildEndpoint(true, "first"), new BitbucketServerEndpoint("Example Inc", "https://bitbucket.example.com/", true, "second"), new BitbucketServerEndpoint("Example Org", "http://example.org:8080/bitbucket/", true, "third") @@ -596,10 +598,10 @@ void given__instanceWithCloudAndServers__when__resolvingNewEndpointAsAnon__then_ void given__instanceWithConfig__when__configRoundtrip__then__configRetained() throws Exception { BitbucketEndpointConfiguration instance = BitbucketEndpointConfiguration.get(); instance.setEndpoints( - Arrays.asList( + List.of( buildEndpoint(true, "first"), - new BitbucketServerEndpoint("Example Inc", "https://bitbucket.example.com/", true, "second"), - new BitbucketServerEndpoint("Example Org", "http://example.org:8080/bitbucket/", false, null) + new BitbucketServerEndpoint("Example Inc", "https://bitbucket.example.com/", true, "second", false, null), + new BitbucketServerEndpoint("Example Org", "http://example.org:8080/bitbucket/", false, null, false, null) )); SystemCredentialsProvider.getInstance().setDomainCredentialsMap( Collections.singletonMap(Domain.global(), Arrays.asList( diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/filesystem/BitbucketSCMFileSystemTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/filesystem/BitbucketSCMFileSystemTest.java index b38a8d413..e543b2bb3 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/filesystem/BitbucketSCMFileSystemTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/filesystem/BitbucketSCMFileSystemTest.java @@ -27,7 +27,7 @@ import com.cloudbees.jenkins.plugins.bitbucket.PullRequestSCMHead; import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketApi; import com.cloudbees.jenkins.plugins.bitbucket.api.PullRequestBranchType; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; import hudson.plugins.git.GitChangeLogParser; import hudson.plugins.git.GitChangeSet; import java.io.ByteArrayInputStream; diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/BitbucketSCMSourcePushHookReceiverTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/BitbucketSCMSourcePushHookReceiverTest.java index f67196bb5..ceb0c0c10 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/BitbucketSCMSourcePushHookReceiverTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/BitbucketSCMSourcePushHookReceiverTest.java @@ -23,9 +23,9 @@ */ package com.cloudbees.jenkins.plugins.bitbucket.hooks; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketEndpointConfiguration; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketServerEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketServerEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.test.util.BitbucketTestUtil; import jakarta.servlet.ReadListener; import jakarta.servlet.ServletInputStream; diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/WebhookAutoRegisterListenerTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/WebhookAutoRegisterListenerTest.java index fc82f64ce..103858a8e 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/WebhookAutoRegisterListenerTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/WebhookAutoRegisterListenerTest.java @@ -26,10 +26,10 @@ import com.cloudbees.jenkins.plugins.bitbucket.BitbucketMockApiFactory; import com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource; import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketApi; +import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketIntegrationClientFactory; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.AbstractBitbucketEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketEndpointConfiguration; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketServerEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketServerEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.impl.util.JsonParser; import com.cloudbees.jenkins.plugins.bitbucket.server.client.repository.NativeBitbucketServerWebhook; import com.cloudbees.jenkins.plugins.bitbucket.test.util.BitbucketTestUtil; @@ -81,15 +81,11 @@ void test_register() throws Exception { StringCredentials credentials = BitbucketTestUtil.registerHookCredentials("password", rule); - AbstractBitbucketEndpoint endpoint = new BitbucketServerEndpoint("datacenter", serverURL, true, "dummyId", true, credentials.getId()); + BitbucketEndpoint endpoint = new BitbucketServerEndpoint("datacenter", serverURL, true, "dummyId", true, credentials.getId()); + ((BitbucketServerEndpoint) endpoint).setBitbucketJenkinsRootUrl("https://jenkins.example.com/"); BitbucketEndpointConfiguration.get().updateEndpoint(endpoint); - BitbucketSCMSource scmSource = new BitbucketSCMSource("amuniz", "test-repos") { - @Override - public String getEndpointJenkinsRootURL() { - return "https://jenkins.example.com/"; - } - }; + BitbucketSCMSource scmSource = new BitbucketSCMSource("amuniz", "test-repos"); scmSource.setServerUrl(serverURL); scmSource.setOwner(getSCMSourceOwnerMock(scmSource)); diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/credentials/BitbucketAccessTokenAuthenticatorSourceTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/credentials/BitbucketAccessTokenAuthenticatorSourceTest.java index be4be2c54..4bbc935b4 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/credentials/BitbucketAccessTokenAuthenticatorSourceTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/credentials/BitbucketAccessTokenAuthenticatorSourceTest.java @@ -24,7 +24,7 @@ package com.cloudbees.jenkins.plugins.bitbucket.impl.credentials; import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketAuthenticator; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; import jenkins.authentication.tokens.api.AuthenticationTokenContext; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/credentials/BitbucketAuthenticatorUtilsTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/credentials/BitbucketAuthenticatorUtilsTest.java index 56c7827d2..382604447 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/credentials/BitbucketAuthenticatorUtilsTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/credentials/BitbucketAuthenticatorUtilsTest.java @@ -23,7 +23,7 @@ */ package com.cloudbees.jenkins.plugins.bitbucket.impl.credentials; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; import com.github.scribejava.core.model.OAuth2AccessTokenErrorResponse; import com.github.scribejava.core.model.OAuthResponseException; import com.github.scribejava.core.model.Response; diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpointDescriptorTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/AbstractBitbucketEndpointDescriptorTest.java similarity index 98% rename from src/test/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpointDescriptorTest.java rename to src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/AbstractBitbucketEndpointDescriptorTest.java index 099c6e926..3bd50772f 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpointDescriptorTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/AbstractBitbucketEndpointDescriptorTest.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package com.cloudbees.jenkins.plugins.bitbucket.endpoints; +package com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint; import com.cloudbees.plugins.credentials.CredentialsScope; import com.cloudbees.plugins.credentials.SystemCredentialsProvider; diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpointTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/AbstractBitbucketEndpointTest.java similarity index 98% rename from src/test/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpointTest.java rename to src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/AbstractBitbucketEndpointTest.java index a5a33e595..5e6d44ffd 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/AbstractBitbucketEndpointTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/AbstractBitbucketEndpointTest.java @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package com.cloudbees.jenkins.plugins.bitbucket.endpoints; +package com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint; import com.cloudbees.plugins.credentials.Credentials; import com.cloudbees.plugins.credentials.CredentialsScope; diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketCloudEndpointTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketCloudEndpointTest.java similarity index 92% rename from src/test/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketCloudEndpointTest.java rename to src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketCloudEndpointTest.java index 7551fb945..2dd6f8540 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketCloudEndpointTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketCloudEndpointTest.java @@ -21,9 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package com.cloudbees.jenkins.plugins.bitbucket.endpoints; +package com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.util.URLUtils; import com.damnhandy.uri.template.UriTemplate; +import hudson.Util; import jenkins.model.Jenkins; import org.junit.jupiter.api.Test; import org.jvnet.hudson.test.JenkinsRule; @@ -72,11 +74,11 @@ void smokes() { @WithJenkins @Test void getUnmanagedDefaultRootUrl(JenkinsRule rule) { - String jenkinsRootURL = Jenkins.get().getRootUrl(); + String jenkinsRootURL = Util.ensureEndsWith(URLUtils.normalizeURL(Jenkins.get().getRootUrl()), "/"); assertThat(new BitbucketCloudEndpoint().getEndpointJenkinsRootUrl()) - .isEqualTo(AbstractBitbucketEndpoint.normalizeJenkinsRootUrl(jenkinsRootURL)); - assertThat(new BitbucketCloudEndpoint(false, 0, 0, false, "{cred}", false, null).getEndpointJenkinsRootUrl()) - .isEqualTo(AbstractBitbucketEndpoint.normalizeJenkinsRootUrl(jenkinsRootURL)); + .isEqualTo(jenkinsRootURL); + assertThat(new BitbucketCloudEndpoint(false, 0, 0, false, "{cred}", false, null).getEndpointJenkinsRootURL()) + .isEqualTo(jenkinsRootURL); } @Test diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpointTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketServerEndpointTest.java similarity index 88% rename from src/test/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpointTest.java rename to src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketServerEndpointTest.java index 22252f4e7..c42197d15 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpointTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/BitbucketServerEndpointTest.java @@ -21,8 +21,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package com.cloudbees.jenkins.plugins.bitbucket.endpoints; +package com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.util.URLUtils; +import hudson.Util; import hudson.util.FormValidation; import jenkins.model.Jenkins; import org.junit.jupiter.api.Test; @@ -39,6 +41,7 @@ void smokes() { assertThat(endpoint.getDisplayName()).isEqualTo("Dummy"); assertThat(endpoint.getServerUrl()).isEqualTo("http://dummy.example.com"); + assertThat(endpoint.getServerURL()).isEqualTo("http://dummy.example.com"); /* The endpoints should set (literally, not normalized) and return * the bitbucketJenkinsRootUrl if the management of hooks is enabled */ @@ -58,21 +61,23 @@ void smokes() { endpoint.setBitbucketJenkinsRootUrl("http://jenkins:8080"); assertThat(endpoint.getBitbucketJenkinsRootUrl()).isEqualTo("http://jenkins:8080/"); assertThat(endpoint.getEndpointJenkinsRootUrl()).isEqualTo("http://jenkins:8080/"); + assertThat(endpoint.getEndpointJenkinsRootURL()).isEqualTo("http://jenkins:8080/"); // Make sure several invokations with same arguments do not conflict: endpoint.setBitbucketJenkinsRootUrl("https://jenkins:443/"); assertThat(endpoint.getBitbucketJenkinsRootUrl()).isEqualTo("https://jenkins/"); assertThat(endpoint.getEndpointJenkinsRootUrl()).isEqualTo("https://jenkins/"); + assertThat(endpoint.getEndpointJenkinsRootURL()).isEqualTo("https://jenkins/"); } @WithJenkins @Test void getUnmanagedDefaultRootUrl(JenkinsRule rule) { - String jenkinsRootURL = Jenkins.get().getRootUrl(); + String jenkinsRootURL = Util.ensureEndsWith(URLUtils.normalizeURL(Jenkins.get().getRootUrl()), "/"); assertThat(new BitbucketServerEndpoint("Dummy", "http://dummy.example.com", true, null, false, null).getEndpointJenkinsRootUrl()) - .isEqualTo(AbstractBitbucketEndpoint.normalizeJenkinsRootUrl(jenkinsRootURL)); - assertThat(new BitbucketServerEndpoint("Dummy", "http://dummy.example.com", false, "{cred}", false, null).getEndpointJenkinsRootUrl()) - .isEqualTo(AbstractBitbucketEndpoint.normalizeJenkinsRootUrl(jenkinsRootURL)); + .isEqualTo(jenkinsRootURL); + assertThat(new BitbucketServerEndpoint("Dummy", "http://dummy.example.com", false, "{cred}", false, null).getEndpointJenkinsRootURL()) + .isEqualTo(jenkinsRootURL); } @Test diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/DummyEndpointConfiguration.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/DummyEndpointConfiguration.java similarity index 91% rename from src/test/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/DummyEndpointConfiguration.java rename to src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/DummyEndpointConfiguration.java index df5375a7b..0432ca7a9 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/DummyEndpointConfiguration.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/endpoint/DummyEndpointConfiguration.java @@ -21,8 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -package com.cloudbees.jenkins.plugins.bitbucket.endpoints; +package com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint; +import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.BitbucketEndpointDescriptor; import com.cloudbees.jenkins.plugins.bitbucket.api.endpoint.EndpointType; import com.damnhandy.uri.template.UriTemplate; import edu.umd.cs.findbugs.annotations.NonNull; @@ -73,7 +74,7 @@ public String getRepositoryUrl(@NonNull String repoOwner, @NonNull String reposi } @Extension // TestExtension could be used only for embedded classes - public static class DescriptorImpl extends AbstractBitbucketEndpointDescriptor { + public static class DescriptorImpl extends BitbucketEndpointDescriptor { } diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/notifier/BitbucketBuildStatusNotificationsJUnit5Test.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/notifier/BitbucketBuildStatusNotificationsJUnit5Test.java index 9182a33ae..71a45babb 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/notifier/BitbucketBuildStatusNotificationsJUnit5Test.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/notifier/BitbucketBuildStatusNotificationsJUnit5Test.java @@ -33,9 +33,9 @@ import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketBuildStatus.Status; import com.cloudbees.jenkins.plugins.bitbucket.api.PullRequestBranchType; import com.cloudbees.jenkins.plugins.bitbucket.client.BitbucketCloudApiClient; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketEndpointConfiguration; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketServerEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketServerEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.impl.notifier.BitbucketBuildStatusNotifications.JobCheckoutListener; import com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient; import com.cloudbees.jenkins.plugins.bitbucket.trait.BitbucketBuildStatusNotificationsTrait; diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/notifier/BitbucketBuildStatusNotificationsTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/notifier/BitbucketBuildStatusNotificationsTest.java index 3410fe880..5f0a4ed50 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/notifier/BitbucketBuildStatusNotificationsTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/impl/notifier/BitbucketBuildStatusNotificationsTest.java @@ -31,8 +31,8 @@ import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketCommit; import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketHref; import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepository; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.filesystem.BitbucketSCMFile; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.trait.BranchDiscoveryTrait; import hudson.model.Descriptor.FormException; import hudson.model.FreeStyleBuild; diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/trait/SCMNavigatorIntegrationTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/trait/SCMNavigatorIntegrationTest.java index 243ae42cf..cda135c42 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/trait/SCMNavigatorIntegrationTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/trait/SCMNavigatorIntegrationTest.java @@ -28,7 +28,7 @@ import com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMNavigator; import com.cloudbees.jenkins.plugins.bitbucket.MockMultiBranchProjectImpl; import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketEndpointConfiguration; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketServerEndpoint; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketServerEndpoint; import hudson.model.ItemGroup; import java.util.EnumSet; import java.util.List; diff --git a/src/test/java/integration/ScanningFailuresTest.java b/src/test/java/integration/ScanningFailuresTest.java index 3ad23c262..b35eeeab6 100644 --- a/src/test/java/integration/ScanningFailuresTest.java +++ b/src/test/java/integration/ScanningFailuresTest.java @@ -30,8 +30,8 @@ import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketCommit; import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketHref; import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepository; -import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.filesystem.BitbucketSCMFile; +import com.cloudbees.jenkins.plugins.bitbucket.impl.endpoint.BitbucketCloudEndpoint; import com.cloudbees.jenkins.plugins.bitbucket.trait.BranchDiscoveryTrait; import com.cloudbees.jenkins.plugins.bitbucket.trait.ForkPullRequestDiscoveryTrait; import com.cloudbees.jenkins.plugins.bitbucket.trait.OriginPullRequestDiscoveryTrait;