Skip to content

Commit cb32459

Browse files
authored
Use BitbucketServer repository browser for Data Center or Server (#929)
1 parent 6390b97 commit cb32459

File tree

3 files changed

+92
-407
lines changed

3 files changed

+92
-407
lines changed

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketGitSCMBuilder.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepository;
2929
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepositoryProtocol;
3030
import com.cloudbees.jenkins.plugins.bitbucket.endpoints.AbstractBitbucketEndpoint;
31+
import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketCloudEndpoint;
3132
import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketEndpointConfiguration;
3233
import com.cloudbees.jenkins.plugins.bitbucket.endpoints.BitbucketServerEndpoint;
3334
import com.cloudbees.jenkins.plugins.sshcredentials.SSHUserPrivateKey;
@@ -38,6 +39,7 @@
3839
import edu.umd.cs.findbugs.annotations.NonNull;
3940
import hudson.Util;
4041
import hudson.plugins.git.GitSCM;
42+
import hudson.plugins.git.browser.BitbucketServer;
4143
import hudson.plugins.git.browser.BitbucketWeb;
4244
import java.util.List;
4345
import jenkins.plugins.git.GitSCMBuilder;
@@ -98,15 +100,19 @@ public BitbucketGitSCMBuilder(@NonNull BitbucketSCMSource scmSource, @NonNull SC
98100
// the clone links
99101
super(head, revision, /*dummy value*/scmSource.getServerUrl(), credentialsId);
100102
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);
103106
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));
105115
}
106-
withBrowser(new BitbucketWeb(endpoint.getRepositoryUrl(
107-
scmSource.getRepoOwner(),
108-
scmSource.getRepository()
109-
)));
110116

111117
// Test for protocol
112118
withCredentials(credentialsId, null);

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketGitSCMRevision.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ public BitbucketGitSCMRevision(@NonNull SCMHead head, @NonNull BitbucketCommit c
5555
super(head, commit.getHash());
5656
this.message = commit.getMessage();
5757
this.author = commit.getAuthor();
58-
Date commitDate;
58+
Date commitDate = null;
5959
try {
60-
commitDate = new StdDateFormat().parse(commit.getDate());
60+
if (commit.getDate() != null) {
61+
commitDate = new StdDateFormat().parse(commit.getDate());
62+
}
6163
} catch (ParseException e) {
6264
commitDate = null;
6365
}

0 commit comments

Comments
 (0)