Skip to content

Commit

Permalink
[JENKINS-49624] Fix selecting credentials for Pipeline Libraries usin…
Browse files Browse the repository at this point in the history
…g Modern SCM (#206)

Comes from JENKINS-44271, applying fix for git-plugin to subversion-plugin
  • Loading branch information
Andne authored and oleg-nenashev committed Mar 3, 2018
1 parent d74359b commit c056e9a
Showing 1 changed file with 7 additions and 7 deletions.
Expand Up @@ -793,7 +793,7 @@ public String getDisplayName() {
* @return list box model.
*/
@SuppressWarnings("unused") // by stapler
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath SCMSourceOwner context,
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item context,
@QueryParameter String remoteBase,
@QueryParameter String credentialsId) {
if (context == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) ||
Expand Down Expand Up @@ -822,7 +822,7 @@ public ListBoxModel doFillCredentialsIdItems(@AncestorInPath SCMSourceOwner cont
* validate the value for a remote (repository) location.
*/
@RequirePOST
public FormValidation doCheckCredentialsId(StaplerRequest req, @AncestorInPath SCMSourceOwner context, @QueryParameter String remoteBase, @QueryParameter String value) {
public FormValidation doCheckCredentialsId(StaplerRequest req, @AncestorInPath Item context, @QueryParameter String remoteBase, @QueryParameter String value) {
// TODO suspiciously similar to SubversionSCM.ModuleLocation.DescriptorImpl.checkCredentialsId; refactor into shared method?
// Test the connection only if we may use the credentials
if (context == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) ||
Expand All @@ -848,7 +848,7 @@ public FormValidation doCheckCredentialsId(StaplerRequest req, @AncestorInPath S
.lookupCredentials(StandardCredentials.class, context, ACL.SYSTEM,
URIRequirementBuilder.fromUri(repoURL.toString()).build()),
CredentialsMatchers.withId(value));
if (checkRepositoryPath(context, repoURL, credentials)!=SVNNodeKind.NONE) {
if (checkRepositoryPath(repoURL, credentials)!=SVNNodeKind.NONE) {
// something exists; now check revision if any

SVNRevision revision = getRevisionFromRemoteUrl(url);
Expand All @@ -862,7 +862,7 @@ public FormValidation doCheckCredentialsId(StaplerRequest req, @AncestorInPath S

SVNRepository repository = null;
try {
repository = getRepository(context, repoURL, credentials,
repository = getRepository(repoURL, credentials,
Collections.<String, Credentials>emptyMap(), null);
long rev = repository.getLatestRevision();
// now go back the tree and find if there's anything that exists
Expand Down Expand Up @@ -908,11 +908,11 @@ public FormValidation doCheckCredentialsId(StaplerRequest req, @AncestorInPath S
return FormValidation.errorWithMarkup(message);
}
}
public SVNNodeKind checkRepositoryPath(SCMSourceOwner context, SVNURL repoURL, StandardCredentials credentials) throws SVNException {
public SVNNodeKind checkRepositoryPath(SVNURL repoURL, StandardCredentials credentials) throws SVNException {
SVNRepository repository = null;

try {
repository = getRepository(context,repoURL,credentials, Collections.<String, Credentials>emptyMap(), null);
repository = getRepository(repoURL,credentials, Collections.<String, Credentials>emptyMap(), null);
repository.testConnection();

long rev = repository.getLatestRevision();
Expand All @@ -937,7 +937,7 @@ public SVNNodeKind checkRepositoryPath(SCMSourceOwner context, SVNURL repoURL, S
}
}

protected SVNRepository getRepository(SCMSourceOwner context, SVNURL repoURL, StandardCredentials credentials,
protected SVNRepository getRepository(SVNURL repoURL, StandardCredentials credentials,
Map<String, Credentials> additionalCredentials, ISVNSession session) throws SVNException {
SVNRepository repository = SVNRepositoryFactory.create(repoURL, session);

Expand Down

0 comments on commit c056e9a

Please sign in to comment.