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

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

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • ssh-slaves-plugin
    • 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);
                   }
               }
           }
      

          [JENKINS-35522] Upgrade to Credentials 2.1.0+ API for populating credentials drop-down

          Stephen Connolly added a comment - https://github.com/jenkinsci/ssh-slaves-plugin/pull/34

          Code changed in jenkins
          User: Jesse Glick
          Path:
          pom.xml
          http://jenkins-ci.org/commit/ssh-slaves-plugin/fedb862bcdd63519ebc0385785d969aa37d251c4
          Log:
          JENKINS-35522 Updated to release after #34.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: pom.xml http://jenkins-ci.org/commit/ssh-slaves-plugin/fedb862bcdd63519ebc0385785d969aa37d251c4 Log: JENKINS-35522 Updated to release after #34.

          Stephan Krull added a comment -

          @stephenconnolly: Could it be that this change lead to problems finding available credentials. This is what I see after adding (another) node to our Jenkins LTS 2.19.4 instance with the latest SSH Slaves plugin version 1.12 installed (and dependent plugin versions: credentials (version:2.1.10), ssh-credentials (version:1.12)):

          The global credentials (that work with every node that is established) do not show up. Please advise if there is need to create a new issue for that.

          BTW: the plugin page needs an update since there still is reference to version 1.11

          Stephan Krull added a comment - @ stephenconnolly : Could it be that this change lead to problems finding available credentials. This is what I see after adding (another) node to our Jenkins LTS 2.19.4 instance with the latest SSH Slaves plugin version 1.12 installed (and dependent plugin versions: credentials (version:2.1.10), ssh-credentials (version:1.12)): The global credentials (that work with every node that is established) do not show up. Please advise if there is need to create a new issue for that. BTW: the plugin page needs an update since there still is reference to version 1.11

          If you have a reproducible test scenario in a clean image then file a JIRA for the credentials issue

          Stephen Connolly added a comment - If you have a reproducible test scenario in a clean image then file a JIRA for the credentials issue

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

              Created:
              Updated:
              Resolved: