in DevOps

Decrypt all Credentials and Private Key values saved in Jenkins vault using Script

Step 1:

Access Script Console:

Go to “Manage Jenkins” then click “Script Console”.

 

Step 2:

Decrypt credentials defined in Jenkins.

Paste and Run below script there.

def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
    com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class,
    Jenkins.instance,
    null,
    null
);
for (c in creds) {
     println( ( c.properties.privateKeySource ? "ID: " + c.id + ", UserName: " + c.username + ", Private Key: " + c.getPrivateKey() : ""))
}
for (c in creds) {
     println( ( c.properties.password ? "ID: " + c.id + ", UserName: " + c.username + ", Password: " + c.password : ""))
}

 

The above script will decode all the Jenkins credentials and Private keys saved.