Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-35522

Upgrade to Credentials 2.1.0+ API for populating credentials drop-down

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      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);
                   }
               }
           }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              stephenconnolly Stephen Connolly
              Reporter:
              stephenconnolly Stephen Connolly
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: