Skip to content

Instantly share code, notes, and snippets.

@jebeaudet
Last active July 6, 2021 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jebeaudet/03d4c33acadb7b89ad9b119fe6db6ab9 to your computer and use it in GitHub Desktop.
Save jebeaudet/03d4c33acadb7b89ad9b119fe6db6ab9 to your computer and use it in GitHub Desktop.
Decrypt jenkins encrypted value
Go to https://jenkinsurl.com/script and run :
println(hudson.util.Secret.decrypt("{encrypted_value}"))
To get the encrypted_value, go to the credential page, click on update and after do inspect element on the password field. Take the "value" property of the field. It should be between curly braces.
To get ALL the 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.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey){
println(String.format("id=%s desc=%s key=%s\n", c.id, c.description, c.privateKeySource.getPrivateKeys()))
}
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))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment