Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>5.27</version>
<version>6.2116.v7501b_67dc517</version>
<relativePath />
</parent>

Expand All @@ -29,6 +29,7 @@
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
<ban-junit4-imports.skip>false</ban-junit4-imports.skip>
<ban-commons-lang-2.skip>false</ban-commons-lang-2.skip>
</properties>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.apache.commons.lang.StringUtils;

import org.eclipse.jgit.transport.RemoteConfig;
import org.eclipse.jgit.transport.URIish;
import com.google.common.base.Objects;
Expand Down Expand Up @@ -194,66 +194,66 @@
}

// needed because bitbucket self hosted does not transfer any host information
if (StringUtils.isEmpty(url.getHost())) {
if (url.getHost() == null || url.getHost().isEmpty()) {
urIish = urIish.setHost(url.getHost());
}

LOGGER.log(Level.FINE, "Trying to match {0} ", urIish.toString() + "<-->" + url);
if (GitStatus.looselyMatches(urIish, url)) {
return true;
} else if (overrideUrl != null && !overrideUrl.isEmpty()) {
LOGGER.log(Level.FINE, "Trying to match using override Repository URL {0} ", overrideUrl + "<-->" + url);
return overrideUrl.contentEquals(url.toString());
}
}
}
} else if (scm instanceof MercurialSCM) {
LOGGER.log(Level.FINEST, "SCM is instance of MercurialSCM");
try {
URI hgUri = new URI(((MercurialSCM) scm).getSource());
String remote = url.toString();
if (looselyMatches(hgUri, remote)) {
return true;
}
} catch (URISyntaxException ex) {
LOGGER.log(Level.SEVERE, "Could not parse jobSource uri: {0} ", ex);
}
} else {
LOGGER.log(Level.FINEST, "SCM is instance of [" + scm.getClass().getSimpleName() + "] which is not supported");
}

return false;
}

private boolean match(SCMSource scm, URIish url) {
if (scm instanceof GitSCMSource || (isBranchPluginAvailable && scm instanceof BitbucketSCMSource)) {
String gitRemote;
if (scm instanceof GitSCMSource) {
LOGGER.log(Level.FINEST, "SCMSource is GitSCMSource");
gitRemote = ((GitSCMSource) scm).getRemote();
} else if (isBranchPluginAvailable) {
LOGGER.log(Level.FINEST, "SCMSource is BitbucketSCMSource");
gitRemote = ((BitbucketSCMSource) scm).getServerUrl() + "/" +
((BitbucketSCMSource) scm).getRepoOwner() + "/" +
((BitbucketSCMSource) scm).getRepository();
} else {
return false;
}
URIish urIish;
LOGGER.log(Level.FINEST, "SCMSource remote is " + gitRemote);
try {
urIish = new URIish(gitRemote);
} catch (URISyntaxException e) {
LOGGER.log(Level.SEVERE, "Could not parse gitRemote: " + gitRemote, e);
return false;
}
// needed cause the ssh and https URI differs in Bitbucket Server.
if (urIish.getPath().startsWith("/scm")) {
urIish = urIish.setPath(urIish.getPath().substring(4));
}

// needed because bitbucket self hosted does not transfer any host information
if (StringUtils.isEmpty(url.getHost())) {
if (url.getHost() == null || url.getHost().isEmpty()) {

Check warning on line 256 in src/main/java/com/cloudbees/jenkins/plugins/BitbucketJobProbe.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 197-256 are not covered by tests
urIish = urIish.setHost(url.getHost());
}

Expand Down
Loading