Advertisement
Guest User

Untitled

a guest
Feb 4th, 2016
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement