|
28 | 28 | import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepository;
|
29 | 29 | import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepositoryProtocol;
|
30 | 30 | import com.cloudbees.jenkins.plugins.bitbucket.endpoints.AbstractBitbucketEndpoint;
|
| 31 | +import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint; |
31 | 32 | import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketEndpointConfiguration;
|
32 | 33 | import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketServerEndpoint;
|
33 | 34 | import com.cloudbees.jenkins.plugins.sshcredentials.SSHUserPrivateKey;
|
|
38 | 39 | import edu.umd.cs.findbugs.annotations.NonNull;
|
39 | 40 | import hudson.Util;
|
40 | 41 | import hudson.plugins.git.GitSCM;
|
| 42 | +import hudson.plugins.git.browser.BitbucketServer; |
41 | 43 | import hudson.plugins.git.browser.BitbucketWeb;
|
42 | 44 | import java.util.List;
|
43 | 45 | import jenkins.plugins.git.GitSCMBuilder;
|
@@ -98,15 +100,19 @@ public BitbucketGitSCMBuilder(@NonNull BitbucketSCMSource scmSource, @NonNull SC
|
98 | 100 | // the clone links
|
99 | 101 | super(head, revision, /*dummy value*/scmSource.getServerUrl(), credentialsId);
|
100 | 102 | this.scmSource = scmSource;
|
101 |
| - AbstractBitbucketEndpoint endpoint = |
102 |
| - BitbucketEndpointConfiguration.get().findEndpoint(scmSource.getServerUrl()); |
| 103 | + |
| 104 | + String serverURL = scmSource.getServerUrl(); |
| 105 | + AbstractBitbucketEndpoint endpoint = BitbucketEndpointConfiguration.get().findEndpoint(serverURL); |
103 | 106 | if (endpoint == null) {
|
104 |
| - endpoint = new BitbucketServerEndpoint(null, scmSource.getServerUrl(), false, null); |
| 107 | + endpoint = new BitbucketServerEndpoint(null, serverURL, false, null); |
| 108 | + } |
| 109 | + |
| 110 | + String repositoryUrl = endpoint.getRepositoryUrl(scmSource.getRepoOwner(), scmSource.getRepository()); |
| 111 | + if (endpoint instanceof BitbucketCloudEndpoint) { |
| 112 | + withBrowser(new BitbucketWeb(repositoryUrl)); |
| 113 | + } else { |
| 114 | + withBrowser(new BitbucketServer(repositoryUrl)); |
105 | 115 | }
|
106 |
| - withBrowser(new BitbucketWeb(endpoint.getRepositoryUrl( |
107 |
| - scmSource.getRepoOwner(), |
108 |
| - scmSource.getRepository() |
109 |
| - ))); |
110 | 116 |
|
111 | 117 | // Test for protocol
|
112 | 118 | withCredentials(credentialsId, null);
|
|
0 commit comments