Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// https://myjenkins.com/script
hashed_pw='{AQAAABAAAAAQB68ttY8Fp7wpTtF/d8VPl8ZU5PZEIJbofSrTgZXxbdY=}'
passwd = hudson.util.Secret.decrypt(hashed_pw)
println(passwd)
@hoto

This comment has been minimized.

Copy link
Owner Author

@hoto hoto commented Apr 25, 2019

Limited to only credentials and ssh keys:

def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
    com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class,
    Jenkins.instance,
    null,
    null
)

creds.each { println("Credentials class: " + it.class) }

println()

for(c in creds) {
  if(c instanceof com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey){
    println(String.format("id=%s  desc=%s key=%s", 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", 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
You can’t perform that action at this time.