Skip to content

Instantly share code, notes, and snippets.

@ababushk
Created August 9, 2021 19:23
Show Gist options
  • Save ababushk/4c79fca83d8536594c4cb46bbb031e20 to your computer and use it in GitHub Desktop.
Save ababushk/4c79fca83d8536594c4cb46bbb031e20 to your computer and use it in GitHub Desktop.
Get Decrypted Jenkins Credentials via Script Console
import jenkins.*
import jenkins.model.*
import hudson.*
import hudson.model.*
def credId = 'my_credentials_id'
def jenkinsCredentials = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
com.cloudbees.plugins.credentials.Credentials.class,
Jenkins.instance,
null,
null
);
for (creds in jenkinsCredentials) {
if (creds.id == credId) {
// may vary because of credential type
println creds.username
println creds.password
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment