Last active
March 28, 2018 12:51
-
-
Save lerrigatto/8fa752970e693d52081e84e482ca0255 to your computer and use it in GitHub Desktop.
jenkins groovy script to list user credentials
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Original Author: kuisathaverat | |
Description: List ID and Description of all credentials on a Jenkins Instance. | |
Source: https://github.com/cloudbees/jenkins-scripts/blob/master/list-credential.groovy | |
Changes: lerrigatto - added credential class name | |
**/ | |
import com.cloudbees.plugins.credentials.Credentials | |
Set<Credentials> allCredentials = new HashSet<Credentials>(); | |
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials( | |
com.cloudbees.plugins.credentials.Credentials.class | |
); | |
allCredentials.addAll(creds) | |
Jenkins.instance.getAllItems(com.cloudbees.hudson.plugins.folder.Folder.class).each{ f -> | |
creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials( | |
com.cloudbees.plugins.credentials.Credentials.class, f) | |
allCredentials.addAll(creds) | |
} | |
for (c in allCredentials) { | |
println(c.id + ": " + c.description + " - "+ c.class.getSimpleName()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment