daily pastebin goal
48%
SHARE
TWEET

Untitled

a guest Feb 4th, 2016 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def getPassword = { username ->
  2.     def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
  3.         com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials.class,
  4.         jenkins.model.Jenkins.instance
  5.     )
  6.  
  7.     def c = creds.findResult { it.username == username ? it : null }
  8.  
  9.     if ( c ) {
  10.         println "found credential ${c.id} for username ${c.username}"
  11.  
  12.         def credentials_store = jenkins.model.Jenkins.instance.getExtensionList(
  13.             'com.cloudbees.plugins.credentials.SystemCredentialsProvider'
  14.             )[0].getStore()
  15.  
  16.          println "result: " + credentials_store
  17.     } else {
  18.       println "could not find credential for ${username}"
  19.     }
  20. }
  21.  
  22. getPassword("XYZ")
  23.    
  24. result: com.cloudbees.plugins.credentials.SystemCredentialsProvider$StoreImpl@1639eab2
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top