Child pages
  • Printing a list of credentials and their IDs
Skip to end of metadata
Go to start of metadata

Printing a list of all the credentials in the system and their IDs.

  def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
      com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class,
      Jenkins.instance,
      null,
      null
  );
  for (c in creds) {
       println(c.id + ": " + c.description)
  }
  • No labels

2 Comments

  1. I see a security risk here, if somebody's credential is configured then anybody who has access to run this script can see the user name and password of all the configured credentials.

    for (c in creds) {
           println(c.id + ": " + c.description)
           
           if(c instanceof com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials)
          

    Unknown macro: {           print c.getUsername()           print c.getPassword()                  }

      }

    1. This is admin anyway.