Skip to content

Commit

Permalink
[JENKINS-16711] If a revision (@NNN) is specified in the repository U…
Browse files Browse the repository at this point in the history
…RL, it is considered in the validation process
  • Loading branch information
recena committed Dec 17, 2015
1 parent 3a9cf51 commit defa208
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/main/java/hudson/scm/SubversionSCM.java
Expand Up @@ -77,11 +77,9 @@
import java.util.LinkedHashSet;
import java.util.WeakHashMap;

import hudson.remoting.LocalChannel;
import hudson.security.ACL;
import hudson.util.ListBoxModel;
import jenkins.model.Jenkins;
import jenkins.model.Jenkins.MasterComputer;
import hudson.remoting.Callable;
import hudson.remoting.Channel;
import hudson.remoting.VirtualChannel;
Expand Down Expand Up @@ -163,6 +161,7 @@
import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory;
import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl;
import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions;
import org.tmatesoft.svn.core.internal.wc.SVNPath;
import org.tmatesoft.svn.core.internal.wc.admin.SVNAdminAreaFactory;
import org.tmatesoft.svn.core.io.SVNCapability;
import org.tmatesoft.svn.core.io.SVNRepository;
Expand Down Expand Up @@ -3077,6 +3076,12 @@ public FormValidation doCheckCredentialsId(StaplerRequest req, @AncestorInPath I
*/
public FormValidation checkCredentialsId(StaplerRequest req, @Nonnull Item context, String remote, String value) {

// Ignore validation if repository URL is empty
String url = Util.fixEmptyAndTrim(remote);
if (url == null) {
return FormValidation.ok();
}

// Is the repository URL parameterized?
if (remote.indexOf('$') != -1) {
return FormValidation.warning("The repository URL is parameterized, connection check skipped");
Expand All @@ -3085,10 +3090,12 @@ public FormValidation checkCredentialsId(StaplerRequest req, @Nonnull Item conte
try {
SVNURL repoURL = SVNURL.parseURIEncoded(remote);
StandardCredentials credentials = lookupCredentials(context, value, repoURL);
SVNRepository repo = descriptor().getRepository(context, repoURL, credentials, Collections.<String, Credentials>emptyMap(), null);
SVNRepository repo = descriptor().getRepository(context, repoURL, credentials, Collections
.<String, Credentials>emptyMap(), null);
String repoRoot = repo.getRepositoryRoot(false).toString();
String repoPath = repo.getLocation().toString().substring(repoRoot.length());
SVNNodeKind svnNodeKind = repo.checkPath(repoPath, SVNRevision.HEAD.getNumber());
SVNPath path = new SVNPath(repoPath, true, true);
SVNNodeKind svnNodeKind = repo.checkPath(path.getTarget(), path.getPegRevision().getNumber());
if (svnNodeKind != SVNNodeKind.DIR) {
return FormValidation.error("Credentials looks fine but the repository URL is invalid");
}
Expand Down

0 comments on commit defa208

Please sign in to comment.