-
-
Save chales/069e3f1bf3ae629d8b9a40e5a54a7ffe to your computer and use it in GitHub Desktop.
Dump jenkins credentials - use in script console
This file contains hidden or 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
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 if (credential instanceof com.microsoft.azure.util.AzureCredentials) { | |
println "AzureCred:" + credential.getSubscriptionId() + " " + credential.getClientId() + " " + credential.getPlainClientSecret() + " " + credential.getTenant() | |
} else { | |
println credential | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment