Skip to content

Instantly share code, notes, and snippets.

@ghsatpute
Created February 5, 2021 11:40
Show Gist options
  • Save ghsatpute/c4377d945b43aa4a5d450870eab9795e to your computer and use it in GitHub Desktop.
Save ghsatpute/c4377d945b43aa4a5d450870eab9795e to your computer and use it in GitHub Desktop.
Read Secret Values from Jenkins

Go to "Manage Jenkins" > "Scripts Console" and run below command.

def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
      com.cloudbees.plugins.credentials.Credentials.class
)
for (c in creds) {
  println(c.id)
  if (c.properties.username) {
    println("   description: " + c.description)
  }
  if (c.properties.username) {
    println("   username: " + c.username)
  }
  if (c.properties.password) {
    println("   password: " + c.password)
  }
  if (c.properties.passphrase) {
    println("   passphrase: " + c.passphrase)
  }
  if (c.properties.secret) {
    println("   secret: " + c.secret)
  }
  if (c.properties.privateKeySource) {
    println("   privateKey: " + c.getPrivateKey())
  }
  println("")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment