Skip to content
Permalink
Browse files
[JENKINS-29211] CredentialsStore is checked before to use
  • Loading branch information
recena committed Jul 8, 2015
1 parent 7b7b165 commit 3ff6d4418094d40c329a4c37326a7e063983f399
Showing with 15 additions and 12 deletions.
  1. +15 −12 src/main/java/hudson/scm/PerJobCredentialStore.java
@@ -112,19 +112,22 @@ private Object writeReplace() {
private static final ThreadLocal<Boolean> IS_SAVING = new ThreadLocal<Boolean>();

/*package*/ void migrateCredentials(SubversionSCM.DescriptorImpl descriptor) throws IOException {
CredentialsStore store = CredentialsProvider.lookupStores(project).iterator().next();
for (Map.Entry<String, Credential> e : credentials.entrySet()) {
StandardCredentials credential = descriptor.migrateCredentials(store, e.getKey(), e.getValue());
ModuleLocation[] locations = ((SubversionSCM) project.getScm()).getLocations();
for (int i = 0; i < locations.length; i++) {
try {
if (e.getKey().contains(locations[i].getSVNURL().getHost())) {
locations[i].setCredentialsId(credential.getId());
break;
Iterable<CredentialsStore> it = CredentialsProvider.lookupStores(project);
if (it != null && it.iterator().hasNext()) {
CredentialsStore store = it.iterator().next();
for (Map.Entry<String, Credential> e : credentials.entrySet()) {
StandardCredentials credential = descriptor.migrateCredentials(store, e.getKey(), e.getValue());
ModuleLocation[] locations = ((SubversionSCM) project.getScm()).getLocations();
for (int i = 0; i < locations.length; i++) {
try {
if (e.getKey().contains(locations[i].getSVNURL().getHost())) {
locations[i].setCredentialsId(credential.getId());
break;
}
} catch (SVNException ex) {
// Should not happen, but...
LOGGER.log(WARNING, "Repository location with a malformed URL: " + locations[i].remote, ex);
}
} catch (SVNException ex) {
// Should not happen, but...
LOGGER.log(WARNING, "Repository location with a malformed URL: " + locations[i].remote, ex);
}
}
}

0 comments on commit 3ff6d44

Please sign in to comment.