Created
August 9, 2021 19:23
-
-
Save ababushk/4c79fca83d8536594c4cb46bbb031e20 to your computer and use it in GitHub Desktop.
Get Decrypted Jenkins Credentials via Script Console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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