Skip to content

Instantly share code, notes, and snippets.

@rhopp
Last active July 28, 2020 16:57
Show Gist options
  • Save rhopp/3b8664aa74be93c14d3edf74b75bdc6a to your computer and use it in GitHub Desktop.
Save rhopp/3b8664aa74be93c14d3edf74b75bdc6a to your computer and use it in GitHub Desktop.
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
com.cloudbees.plugins.credentials.Credentials.class
)
for (c in creds) {
println(c.id)
println(c.class)
if (c.properties.username) {
println(" description: " + c.description)
}
if (c.properties.username) {
println(" username: " + c.username)
}
if (c.properties.password) {
println(" password: " + c.password)
}
if (c.properties.passphrase) {
println(" passphrase: " + c.passphrase)
}
if (c.properties.secret) {
println(" secret: " + c.secret)
}
if (c.properties.privateKeySource) {
println(" privateKey: " + c.getPrivateKey())
}
if (c instanceof org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl){
println(" "+c.getContent().getText());
}
if (c instanceof com.dabsquared.gitlabjenkins.connection.GitLabApiTokenImpl){
println(" "+c.getApiToken());
}
println("")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment