Technotes

Technotes for future me

Jenkins dump credentials

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 org.jenkinsci.plugins.plaincredentials.impl.*

domain = Domain.global()
store = SystemCredentialsProvider.getInstance().getStore()

for (credential in store.getCredentials(domain)) {
if (credential instanceof UsernamePasswordCredentialsImpl) {
println credential.getId() + " " + credential.getUsername() + " " + credential.getPassword().getPlainText()
} else if (credential instanceof StringCredentialsImpl) {
println credential.getId() + " " + credential.getSecret().getPlainText()
} else if(credential instanceof BasicSSHUserPrivateKey) {
println credential.getId() + " " + credential.getUsername() + "\n" + credential.getPrivateKey()
} else {
println credential
}

}
Last updated on 10 Mar 2022
Published on 10 Mar 2022
Edit on GitHub