Skip to content
Permalink
Browse files
[JENKINS-35540] Upgrade to Credentials 2.1.0+ API for populating cred…
…entials drop-down (#21)

* [JENKINS-35540] upgraded to credentials 2.1.x
* added Jenkinsfile
* [JENKINS-35540] adding also user crendentials
  • Loading branch information
escoem committed Oct 26, 2017
1 parent c38afcd commit e05b69db3ef6c9fcfdd61fcb17068c4eb135f055
@@ -0,0 +1 @@
buildPlugin()
@@ -106,12 +106,12 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>1.24</version>
<version>2.1.13</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>cloudbees-folder</artifactId>
<version>5.12</version>
<version>6.0.4</version>
</dependency>

<dependency>
@@ -24,13 +24,18 @@

package org.jenkins.ci.plugins.jobimport;

import com.cloudbees.plugins.credentials.CredentialsMatchers;
import com.cloudbees.plugins.credentials.common.StandardListBoxModel;
import com.cloudbees.plugins.credentials.common.StandardUsernameListBoxModel;
import com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials;
import com.cloudbees.plugins.credentials.domains.DomainRequirement;
import hudson.Extension;
import hudson.model.Describable;
import hudson.model.Descriptor;
import hudson.model.Item;
import hudson.model.RootAction;
import hudson.model.TopLevelItem;
import hudson.security.ACL;
import hudson.util.FormValidation;
import hudson.util.ListBoxModel;
import jenkins.model.Jenkins;
@@ -52,6 +57,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
@@ -272,9 +278,21 @@ public static final class JobImportActionDescriptor extends Descriptor<JobImport
public String getDisplayName() { return ""; }

public ListBoxModel doFillCredentialIdItems() {
return new StandardUsernameListBoxModel()
.withEmptySelection()
.withAll(allCredentials());
return new StandardListBoxModel()
.includeEmptyValue()
.includeMatchingAs(
Jenkins.getAuthentication(),
Jenkins.getInstance(),
StandardUsernamePasswordCredentials.class,
Collections.<DomainRequirement>emptyList(),
CredentialsMatchers.always()
).includeMatchingAs(
ACL.SYSTEM,
Jenkins.getInstance(),
StandardUsernamePasswordCredentials.class,
Collections.<DomainRequirement>emptyList(),
CredentialsMatchers.always()
);
}
}
}
@@ -30,6 +30,7 @@ public static NullSafeCredentials getCredentials(String credentialId) {
return new NullSafeCredentials();
}

@Deprecated
public static List<StandardUsernamePasswordCredentials> allCredentials() {
return CredentialsProvider.lookupCredentials(
StandardUsernamePasswordCredentials.class,

0 comments on commit e05b69d

Please sign in to comment.