Update credentials-plugin to version 2.1.0 (JENKINS-35538)

This commit is contained in:
Robin Müller 2016-06-14 22:11:41 +02:00
parent 44648f7d67
commit 090fa9a546
2 changed files with 9 additions and 12 deletions

View File

@ -174,7 +174,7 @@
<dependency> <dependency>
<groupId>org.jenkins-ci.plugins</groupId> <groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId> <artifactId>credentials</artifactId>
<version>1.28</version> <version>2.1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.jenkins-ci.plugins</groupId> <groupId>org.jenkins-ci.plugins</groupId>

View File

@ -2,7 +2,6 @@ package com.dabsquared.gitlabjenkins.connection;
import com.cloudbees.plugins.credentials.Credentials; import com.cloudbees.plugins.credentials.Credentials;
import com.cloudbees.plugins.credentials.CredentialsMatcher; import com.cloudbees.plugins.credentials.CredentialsMatcher;
import com.cloudbees.plugins.credentials.CredentialsProvider;
import com.cloudbees.plugins.credentials.common.AbstractIdCredentialsListBoxModel; import com.cloudbees.plugins.credentials.common.AbstractIdCredentialsListBoxModel;
import com.cloudbees.plugins.credentials.common.StandardCredentials; import com.cloudbees.plugins.credentials.common.StandardCredentials;
import com.cloudbees.plugins.credentials.common.StandardListBoxModel; import com.cloudbees.plugins.credentials.common.StandardListBoxModel;
@ -26,6 +25,7 @@ import org.kohsuke.stapler.StaplerRequest;
import javax.ws.rs.ProcessingException; import javax.ws.rs.ProcessingException;
import javax.ws.rs.WebApplicationException; import javax.ws.rs.WebApplicationException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -70,7 +70,6 @@ public class GitLabConnectionConfig extends GlobalConfiguration {
return clients.get(connectionName); return clients.get(connectionName);
} }
//TODO: remove if superfluous!
public FormValidation doCheckName(@QueryParameter String id, @QueryParameter String value) { public FormValidation doCheckName(@QueryParameter String id, @QueryParameter String value) {
if (StringUtils.isEmptyOrNull(value)) { if (StringUtils.isEmptyOrNull(value)) {
return FormValidation.error(Messages.name_required()); return FormValidation.error(Messages.name_required());
@ -89,7 +88,6 @@ public class GitLabConnectionConfig extends GlobalConfiguration {
} }
} }
// TODO check why this gets called twice on page load once with the correct id and once with an empty string
public FormValidation doCheckApiTokenId(@QueryParameter String value) { public FormValidation doCheckApiTokenId(@QueryParameter String value) {
if (StringUtils.isEmptyOrNull(value)) { if (StringUtils.isEmptyOrNull(value)) {
return FormValidation.error(Messages.apiToken_required()); return FormValidation.error(Messages.apiToken_required());
@ -132,15 +130,15 @@ public class GitLabConnectionConfig extends GlobalConfiguration {
public ListBoxModel doFillApiTokenIdItems(@QueryParameter String name) { public ListBoxModel doFillApiTokenIdItems(@QueryParameter String name) {
if (Jenkins.getInstance().hasPermission(Item.CONFIGURE)) { if (Jenkins.getInstance().hasPermission(Item.CONFIGURE)) {
AbstractIdCredentialsListBoxModel<StandardListBoxModel, StandardCredentials> options = new StandardListBoxModel() AbstractIdCredentialsListBoxModel<StandardListBoxModel, StandardCredentials> options = new StandardListBoxModel()
.withEmptySelection() .includeEmptyValue()
.withMatching( .includeMatchingAs(ACL.SYSTEM,
new GitLabCredentialMatcher(), Jenkins.getActiveInstance(),
CredentialsProvider.lookupCredentials( StringCredentials.class,
StandardCredentials.class, Jenkins.getInstance(), ACL.SYSTEM, new ArrayList<DomainRequirement>() Collections.<DomainRequirement>emptyList(),
) new GitLabCredentialMatcher());
);
if (name != null && connectionMap.containsKey(name)) { if (name != null && connectionMap.containsKey(name)) {
String apiTokenId = connectionMap.get(name).getApiTokenId(); String apiTokenId = connectionMap.get(name).getApiTokenId();
options.includeCurrentValue(apiTokenId);
for (ListBoxModel.Option option : options) { for (ListBoxModel.Option option : options) {
if (option.value.equals(apiTokenId)) { if (option.value.equals(apiTokenId)) {
option.selected = true; option.selected = true;
@ -149,7 +147,6 @@ public class GitLabConnectionConfig extends GlobalConfiguration {
} }
return options; return options;
} }
return new StandardListBoxModel(); return new StandardListBoxModel();
} }