Skip to content

Commit

Permalink
[FIXED JENKINS-35563] Upgrade to Credentials 2.1.0+ API for populatin…
Browse files Browse the repository at this point in the history
…g credentials drop-down
  • Loading branch information
stephenc committed Jun 10, 2016
1 parent 278108f commit 9ce369c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -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>
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
);
}

}
Expand Down
@@ -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;
Expand Down Expand Up @@ -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()
);
}

}
Expand Down

0 comments on commit 9ce369c

Please sign in to comment.