Skip to content

Commit

Permalink
Use BitbucketServer repository browser for Data Center or Server (#929)
Browse files Browse the repository at this point in the history
  • Loading branch information
nfalco79 authored Nov 28, 2024
1 parent 6390b97 commit cb32459
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 407 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepository;
import com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketRepositoryProtocol;
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.sshcredentials.SSHUserPrivateKey;
Expand All @@ -38,6 +39,7 @@
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Util;
import hudson.plugins.git.GitSCM;
import hudson.plugins.git.browser.BitbucketServer;
import hudson.plugins.git.browser.BitbucketWeb;
import java.util.List;
import jenkins.plugins.git.GitSCMBuilder;
Expand Down Expand Up @@ -98,15 +100,19 @@ public BitbucketGitSCMBuilder(@NonNull BitbucketSCMSource scmSource, @NonNull SC
// the clone links
super(head, revision, /*dummy value*/scmSource.getServerUrl(), credentialsId);
this.scmSource = scmSource;
AbstractBitbucketEndpoint endpoint =
BitbucketEndpointConfiguration.get().findEndpoint(scmSource.getServerUrl());

String serverURL = scmSource.getServerUrl();
AbstractBitbucketEndpoint endpoint = BitbucketEndpointConfiguration.get().findEndpoint(serverURL);
if (endpoint == null) {
endpoint = new BitbucketServerEndpoint(null, scmSource.getServerUrl(), false, null);
endpoint = new BitbucketServerEndpoint(null, serverURL, false, null);
}

String repositoryUrl = endpoint.getRepositoryUrl(scmSource.getRepoOwner(), scmSource.getRepository());
if (endpoint instanceof BitbucketCloudEndpoint) {
withBrowser(new BitbucketWeb(repositoryUrl));
} else {
withBrowser(new BitbucketServer(repositoryUrl));
}
withBrowser(new BitbucketWeb(endpoint.getRepositoryUrl(
scmSource.getRepoOwner(),
scmSource.getRepository()
)));

// Test for protocol
withCredentials(credentialsId, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ public BitbucketGitSCMRevision(@NonNull SCMHead head, @NonNull BitbucketCommit c
super(head, commit.getHash());
this.message = commit.getMessage();
this.author = commit.getAuthor();
Date commitDate;
Date commitDate = null;
try {
commitDate = new StdDateFormat().parse(commit.getDate());
if (commit.getDate() != null) {
commitDate = new StdDateFormat().parse(commit.getDate());
}
} catch (ParseException e) {
commitDate = null;
}
Expand Down
Loading

0 comments on commit cb32459

Please sign in to comment.