Skip to content
Permalink
Browse files

[FIXED JENKINS-35563] Upgrade to Credentials 2.1.0+ API for populatin…

…g credentials drop-down
  • Loading branch information...
stephenc committed Jun 10, 2016
1 parent 278108f commit 9ce369cf780655a78921e5a4f07296be1977f8e5
@@ -122,7 +122,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>credentials</artifactId>
<version>1.22</version>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
@@ -41,6 +41,8 @@
import hudson.model.BuildListener;
import hudson.model.Descriptor;
import hudson.model.Item;
import hudson.model.Queue;
import hudson.model.queue.Tasks;
import hudson.security.ACL;
import hudson.tasks.BuildWrapper;
import hudson.tasks.BuildWrapperDescriptor;
@@ -488,10 +490,14 @@ public String getDisplayName() {
@SuppressWarnings("unused") // used by stapler
public ListBoxModel doFillIdItems() {
Item item = Stapler.getCurrentRequest().findAncestorObject(Item.class);
return new StandardUsernameListBoxModel().withMatching(SSHAuthenticator.matcher(),
CredentialsProvider.lookupCredentials(SSHUserPrivateKey.class, item, ACL.SYSTEM,
Collections.<DomainRequirement>emptyList())
);
return new StandardUsernameListBoxModel()
.includeMatchingAs(
item instanceof Queue.Task ? Tasks.getAuthenticationOf((Queue.Task) item) : ACL.SYSTEM,
item,
SSHUserPrivateKey.class,
Collections.<DomainRequirement>emptyList(),
SSHAuthenticator.matcher()
);
}

}
@@ -1,11 +1,14 @@
package com.cloudbees.jenkins.plugins.sshagent;

import com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator;
import com.cloudbees.jenkins.plugins.sshcredentials.SSHUserPrivateKey;
import com.cloudbees.plugins.credentials.CredentialsProvider;
import com.cloudbees.plugins.credentials.common.StandardUsernameListBoxModel;
import com.cloudbees.plugins.credentials.domains.DomainRequirement;
import hudson.Extension;
import hudson.model.Item;
import hudson.model.Queue;
import hudson.model.queue.Tasks;
import hudson.security.ACL;
import hudson.util.ListBoxModel;
import org.jenkinsci.plugins.workflow.steps.AbstractStepDescriptorImpl;
@@ -75,10 +78,14 @@ public boolean takesImplicitBlockArgument() {
@SuppressWarnings("unused") // used by stapler
public ListBoxModel doFillCredentialsItems() {
Item item = Stapler.getCurrentRequest().findAncestorObject(Item.class);
return new StandardUsernameListBoxModel().withAll(
CredentialsProvider.lookupCredentials(SSHUserPrivateKey.class, item, ACL.SYSTEM,
Collections.<DomainRequirement>emptyList())
);
return new StandardUsernameListBoxModel()
.includeMatchingAs(
item instanceof Queue.Task ? Tasks.getAuthenticationOf((Queue.Task)item) : ACL.SYSTEM,
item,
SSHUserPrivateKey.class,
Collections.<DomainRequirement>emptyList(),
SSHAuthenticator.matcher()
);
}

}

0 comments on commit 9ce369c

Please sign in to comment.
You can’t perform that action at this time.