Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hudson.util.Secret
- import groovy.json.JsonOutput
- import groovy.json.JsonSlurper
- def static getCredentialsAtFolder(folderName){
- def folders = Jenkins.getInstance().getAllItems(com.cloudbees.hudson.plugins.folder.Folder.class)
- def credentials = []
- for(f in folders){
- if(f.name == folderName){
- def stores = com.cloudbees.plugins.credentials.CredentialsProvider.lookupStores(f);
- for (s in stores) {
- if (s.getContext() == f) {
- def folderStore = s;
- def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
- com.cloudbees.plugins.credentials.Credentials.class,
- f
- )
- for(c in creds){
- credentials.push(c)
- }
- }
- }
- }
- }
- return credentials
- }
- def _creds = getCredentialsAtFolder("crm-campaings")
- for (c in _creds) {
- if(c.id.contains("JKS_SQL_LEGACY_CONN_STR")){
- def slurper = new JsonSlurper().parseText(JsonOutput.toJson(c.getSecret()))
- println(slurper.plainText)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement