Guest User

cyrus_mc

a guest
Feb 21st, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. import groovy.json.JsonSlurper
  2.  
  3. @NonCPS
  4. def parseResponse(response) {
  5. def list = new JsonSlurper().parseText( response )
  6.  
  7. def repositories = []
  8. for (Map item : list) {
  9. repositories.push(item.ssh_url)
  10. //println "${item.ssh_url}"
  11. }
  12. return repositories
  13. }
  14.  
  15. podTemplate(label: 'mypod', containers: [
  16. containerTemplate(name: 'golang', image: 'golang:1.6.3', ttyEnabled: true, command: 'cat')
  17. ]) {
  18.  
  19. node ('mypod') {
  20. stage 'Find Repositories'
  21.  
  22. // make call to GitHub API to list all repositories for Beacon project
  23. def response = httpRequest "https://api.github.com/teams/xxxx/repos?access_token=xxxx"
  24.  
  25. // parse the response and write out a file containing the list of repositories
  26. def repositories = parseResponse(response.content)
  27.  
  28. container('golang') {
  29. stage 'Checkout Repositories'
  30.  
  31. for (String item : repositories) {
  32. git branch: 'master', credentialsId: '00b7a06b-b621-476f-a147-ec08b70c391e', url: item
  33. }
  34.  
  35. //git branch: 'master', url: '[email protected]:XXXX/activeMqMessageQueueing.git', credentialsId: '00b7a06b-b621-476f-a147-ec08b70c391e'
  36. sh """
  37. sleep 600
  38. """
  39.  
  40. }
  41.  
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment