Skip to content

Commit

Permalink
[JENKINS-29211] CredentialsStore is checked before to use
Browse files Browse the repository at this point in the history
  • Loading branch information
recena committed Jul 8, 2015
1 parent 7b7b165 commit 3ff6d44
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/main/java/hudson/scm/PerJobCredentialStore.java
Expand Up @@ -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);
}
}
}
Expand Down

0 comments on commit 3ff6d44

Please sign in to comment.