Skip to content

Instantly share code, notes, and snippets.

@alkuzad
Last active September 5, 2022 15:42
Show Gist options
  • Save alkuzad/225ecee24b63f852f49a150d1e649c87 to your computer and use it in GitHub Desktop.
Save alkuzad/225ecee24b63f852f49a150d1e649c87 to your computer and use it in GitHub Desktop.
import jenkins.*
import jenkins.model.*
import hudson.*
import hudson.model.*
import org.apache.commons.io.IOUtils
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 == "some-uuid-like-d0c63045-3999-43d1-80b4-17b361412500"){
// For SecretFile
println(IOUtils.toString(creds.getContent(), "UTF-8"))
// For Username / Password
// println(creds.username)
// println(creds.password)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment