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

Retrieving a username/password credential

XMLWordPrintable

      Hi,

      I'm new to Jenkins and I'm trying to build a plugin. Are there any full working examples that show how to set/retrieve a username/password from Jenkins. I'm specifically referring to this https://github.com/jenkinsci/credentials-plugin/blob/master/docs/consumer.adoc

      public ListBoxModel doFillCredentialsIdItems(
              @AncestorInPath Item item,
              @QueryParameter String credentialsId,
              ... (1)
              ) {
        StandardListBoxModel result = new StandardListBoxModel();
        if (item == null) {
          if (!Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)) {
            return result.includeCurrentValue(credentialsId); (2)
          }
        } else {
          if (!item.hasPermission(Item.EXTENDED_READ)
              && !item.hasPermission(CredentialsProvider.USE_ITEM)) {
            return result.includeCurrentValue(credentialsId); (2)
          }
        }
        return result
          .includeEmptySelection() (3)
          .includeMatchingAs(...) (4)
          .includeCurrentValue(credentialsId); (5)
      }
      

      I'm getting stuck at step 4 in the example, what should I do here? I've tried looking at the other plugins to see how they implement this but I'm get lost quickly. Is there a simple demo that shows how this works? 

       

       

       

            Unassigned Unassigned
            carlskii Carl Bourne
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: