Last active
March 6, 2019 00:17
-
-
Save marcosborges/5f62e0bfeaf9999d01eb5fb1a3954b82 to your computer and use it in GitHub Desktop.
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
def folders = Jenkins.getInstance().getAllItems(com.cloudbees.hudson.plugins.folder.Folder.class) | |
for(f in folders){ | |
println "FOLDER: ${f.name}" | |
def stores = com.cloudbees.plugins.credentials.CredentialsProvider.lookupStores(f); | |
for (s in stores) { | |
switch(s.getContext().getClass()){ | |
case com.cloudbees.hudson.plugins.folder.Folder: | |
println " STORE: ${s.getContext().name}"; | |
if (s.getContext() == f) { | |
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials( | |
com.cloudbees.plugins.credentials.Credentials.class, | |
f | |
) | |
for(c in creds) { | |
if (c.getScope() == null){ | |
switch(c.getClass()){ | |
case org.jenkinsci.plugins.plaincredentials.impl.StringCredentialsImpl: | |
println " ${c.id}: ${c.getSecret()}" | |
break; | |
case org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl: | |
println " ${c.id}: ${c.getFileName()}" | |
//println " ${c.id}: ${c.getContent()}" | |
break; | |
case com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl: | |
println " ${c.id}: ${c.getUsername()}" | |
break; | |
case com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey: | |
println " ${c.id}: ${c.getUsername()}" | |
break; | |
default : | |
println " ${c.getClass()}" | |
break; | |
} | |
} | |
} | |
} | |
break; | |
case hudson.model.Hudson: | |
//println s.getContext().url; | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment