-
Improvement
-
Resolution: Fixed
-
Minor
-
None
Mostly a question of changing the doFillXXX methods like so
@@ -1471,18 +1473,28 @@ public class SSHLauncher extends ComputerLauncher { public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context, @QueryParameter String host, - @QueryParameter String port) { + @QueryParameter String port, + @QueryParameter String value) { AccessControlled _context = (context instanceof AccessControlled ? (AccessControlled) context : Jenkins.getInstance()); if (_context == null || !_context.hasPermission(Computer.CONFIGURE)) { - return new ListBoxModel(); + return new StandardUsernameListBoxModel() + .includeCurrentValue(value); } try { int portValue = Integer.parseInt(port); - return new StandardUsernameListBoxModel().withMatching(SSHAuthenticator.matcher(Connection.class), - CredentialsProvider.lookupCredentials(StandardUsernameCredentials.class, context, - ACL.SYSTEM, SSHLauncher.SSH_SCHEME, new HostnamePortRequirement(host, portValue))); + return new StandardUsernameListBoxModel() + .includeMatchingAs( + ACL.SYSTEM, + Jenkins.getActiveInstance(), + StandardUsernameCredentials.class, + Collections.<DomainRequirement>singletonList( + new HostnamePortRequirement(host, portValue) + ), + SSHAuthenticator.matcher(Connection.class)) + .includeCurrentValue(value); // always add the current value last in case already present } catch (NumberFormatException ex) { - return new ListBoxModel(); + return new StandardUsernameListBoxModel() + .includeCurrentValue(value); } } }
- relates to
-
JENKINS-35545 Upgrade to Credentials 2.1.0+ API for populating credentials drop-down
- Closed