Child pages
  • Printing a list of credentials and their IDs

Due to some maintenance issues, this service has been switched in read-only mode, you can find more information about the why

and how to migrate your plugin documentation in this blogpost

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. Unknown User (ramakrishnaraov)

    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. Unknown User (akostadinov)

      This is admin anyway.