Skip to content

Instantly share code, notes, and snippets.

@jbouse
Forked from timja/jenkins-dump-credentials.groovy
Last active August 26, 2020 20:12
Show Gist options
  • Save jbouse/8f396932bd6f4939be2079f585a88a86 to your computer and use it in GitHub Desktop.
Save jbouse/8f396932bd6f4939be2079f585a88a86 to your computer and use it in GitHub Desktop.
Dump jenkins credentials - use in script console
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.common.*
import com.cloudbees.plugins.credentials.domains.*
import com.cloudbees.plugins.credentials.impl.*
import com.cloudbees.jenkins.plugins.sshcredentials.impl.*
import com.cloudbees.jenkins.plugins.awscredentials.*
import org.jenkinsci.plugins.plaincredentials.impl.*
import hudson.plugins.blazemeter.*
domain = Domain.global()
store = SystemCredentialsProvider.getInstance().getStore()
for (credential in store.getCredentials(domain)) {
if (credential instanceof UsernamePasswordCredentialsImpl) {
println "- usernamePassword:\n description: " + credential.description + "\n id: " + credential.id + "\n scope: " + credential.scope + "\n username: " + credential.username + "\n password: " + credential.password.plainText + "\n"
} else if (credential instanceof StringCredentialsImpl) {
println "SecretText: " + credential.id + " " + credential.secret.plainText
} else if(credential instanceof BasicSSHUserPrivateKey) {
println "SSH: " + credential.id + " " + credential.username + "\n" + credential.privateKey
} else if(credential instanceof FileCredentialsImpl) {
println "File: " + credential.id + " " + credential.fileName + "\n" + credential.secretBytes
} else if(credential instanceof AWSCredentialsImpl) {
println "- aws:\n description: " + credential.description + "\n id: " + credential.id + "\n accessKey: " + credential.accessKey + "\n secretKey: " + credential.secretKey.plainText + "\n"
} else if(credential instanceof BlazemeterCredentialsBAImpl) {
println "BlazeMeter: " + credential.id + " " + credential.username + " " + credential.password.plainText
} else {
println credential.class
println credential.class.collect{c -> [c.declaredMethods,c.methods]}.flatten()*.name as SortedSet
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment