Skip to content

Commit

Permalink
Merge pull request #143 from recena/JENKINS-30774
Browse files Browse the repository at this point in the history
[JENKINS-30774] Simplify the repository validation
  • Loading branch information
recena committed Nov 4, 2015
2 parents 8a76821 + 30883d4 commit 6a822a2
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 109 deletions.
25 changes: 9 additions & 16 deletions src/main/java/hudson/scm/SubversionSCM.java
Expand Up @@ -3075,22 +3075,22 @@ public FormValidation doCheckCredentialsId(StaplerRequest req, @AncestorInPath I
* Validate the value for a remote (repository) location.
*/
public FormValidation checkCredentialsId(StaplerRequest req, @Nonnull Item context, String remote, String value) {
// if check remote is reporting an issue then we don't need to
String url = Util.fixEmptyAndTrim(remote);
if (url == null) {
return FormValidation.ok();
}

if (descriptor().isValidateRemoteUpToVar()) {
url = (url.indexOf('$') != -1) ? url.substring(0, url.indexOf('$')) : url;
} else {
url = new EnvVars(EnvVars.masterEnvVars).expand(url);
}

// TODO: It would be interesting to include global variables.
url = new EnvVars(EnvVars.masterEnvVars).expand(url);
if (!URL_PATTERN.matcher(url).matches()) {
return FormValidation.ok();
}

// Is the repository URL parameterized?
if (url.indexOf('$') != -1) {
return FormValidation.warning("This repository URL is parameterized, validation skipped.");
}

try {
String urlWithoutRevision = SvnHelper.getUrlWithoutRevision(url);

Expand Down Expand Up @@ -3147,15 +3147,8 @@ public FormValidation checkCredentialsId(StaplerRequest req, @Nonnull Item conte
}
}
} catch (SVNException e) {
LOGGER.log(Level.INFO, "Failed to access subversion repository: " + url, e);
String message = Messages.SubversionSCM_doCheckRemote_exceptionMsg1(
Util.escape(url), Util.escape(e.getErrorMessage().getFullMessage()),
"javascript:document.getElementById('svnerror').style.display='block';"
+ "document.getElementById('svnerrorlink').style.display='none';"
+ "return false;")
+ "<br/><pre id=\"svnerror\" style=\"display:none\">"
+ Functions.printThrowable(e) + "</pre>";
return FormValidation.errorWithMarkup(message);
LOGGER.log(Level.SEVERE, "Unable to access to subversion repository. " + e.getMessage());
return FormValidation.error("Unable to access to subversion repository");
}
}

Expand Down
5 changes: 0 additions & 5 deletions src/main/resources/hudson/scm/SubversionSCM/global.jelly
Expand Up @@ -37,10 +37,5 @@ THE SOFTWARE.
<f:entry title="${%Exclusion revprop name}" help="/descriptor/hudson.scm.SubversionSCM/help/excludedRevprop">
<f:textbox name="svn.global_excluded_revprop" value="${descriptor.globalExcludedRevprop}"/>
</f:entry>
<f:optionalBlock
name="svn.validateRemoteUpToVar"
checked="${descriptor.validateRemoteUpToVar}"
title="${%Validate repository URLs up to the first variable name}"
help="/descriptor/hudson.scm.SubversionSCM/help/validateRemoteUpToVar"/>
</f:section>
</j:jelly>

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 6a822a2

Please sign in to comment.