Advertisement
Guest User

Untitled

a guest
Dec 13th, 2016
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 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 systemCredentialsProvider = jenkins.model.Jenkins.instance.getExtensionList(
  13. 'com.cloudbees.plugins.credentials.SystemCredentialsProvider'
  14. ).first()
  15.  
  16. def password = systemCredentialsProvider.credentials.first().password
  17.  
  18. println password
  19.  
  20.  
  21. } else {
  22. println "could not find credential for ${username}"
  23. }
  24. }
  25.  
  26. getPassword("laura")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement