https://www.notion.so/Useful-Scripts-for-Jenkins-a0fc6caf2cdc43c6a45f406e816c2d5d
Decrypt credentials defined in Jenkins and list values.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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.properties.privateKeySource) {
println("ID: " + c.id)
println("UserName: " + c.username)
println("Description: " + c.description)
println("Private Key: " + c.getPrivateKey() )
}
}
Decrypt the password if you got its HASH.
1
2
3
println(hudson.util.Secret.decrypt("{HASHxxxxx=}"))
# or /////
println(hudson.util.Secret.fromString("{HASHxxxxx=}").getPlainText())