Skip to content

Instantly share code, notes, and snippets.

@hoto
Created January 10, 2019 16:55
Show Gist options
  • Save hoto/d1c874480888f8711f12db33a20b6e4d to your computer and use it in GitHub Desktop.
Save hoto/d1c874480888f8711f12db33a20b6e4d to your computer and use it in GitHub Desktop.
// https://myjenkins.com/script
hashed_pw='{AQAAABAAAAAQB68ttY8Fp7wpTtF/d8VPl8ZU5PZEIJbofSrTgZXxbdY=}'
passwd = hudson.util.Secret.decrypt(hashed_pw)
println(passwd)
@hoto
Copy link
Author

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