Skip to content

Instantly share code, notes, and snippets.

@lkraider
Created March 7, 2025 18:46
Show Gist options
  • Save lkraider/0f8430e8530f855cf3af1be097ff4728 to your computer and use it in GitHub Desktop.
Save lkraider/0f8430e8530f855cf3af1be097ff4728 to your computer and use it in GitHub Desktop.
Dump Jenkins Credentials
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class,
Jenkins.instance,
null,
null
)
for(c in creds) {
if (c instanceof com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl){
println(String.format("id=%s desc=%s user=%s pass=%s\n", c.id, c.description, c.username, c.password))
}
}
for(c in creds) {
if(c instanceof com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey){
println(String.format("id=%s desc=%s key=\n%s\npassphrase=%s\n", c.id, c.description, c.privateKeySource.getPrivateKeys(), c.getPassphrase()))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment