Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. import groovy.json.JsonSlurper
  2.  
  3. def parser_job_name = env.JOB_NAME.tokenize( '.' )
  4. def env_name = parser_job_name[0]
  5.  
  6. env.CREATED_INSTANCES_FILE_PATH = 'instance_ids_' + env.BUILD_ID + '.json'
  7.  
  8. def provisionInstances() {
  9. def parser_job_name = env.JOB_NAME.tokenize( '.' )
  10. def env_name = parser_job_name[0]
  11. stage("provisioning ${env.number_of_instances} ${env.component_name} instances")
  12. build job : 'qa' + '.' + 'provision.AWS_Provisioning_System',
  13. parameters: [[$class: 'StringParameterValue', name: 'DESIRED_NUMBER_OF_INSTANCES', value: env.number_of_instances],
  14. [$class: 'StringParameterValue', name: 'INSTANCE_TYPE', value: env.instance_type]]
  15. def instance_ids_file = new File('/var/lib/jenkins/workspace/' + env_name + '.' + 'provision.AWS_Provisioning_System' + '/' + env.CREATED_INSTANCES_FILE_PATH)
  16. def jsonSlurper2 = new JsonSlurper()
  17. def instance_ids = jsonSlurper2.parseText(instance_ids_file.text)
  18. jsonSlurper2 = null
  19. env.INSTANCE_ID = instance_ids.created_instance_ids
  20. all_created_instances << env.INSTANCE_ID
  21. instance_ids = null
  22. }
  23.  
  24. def iterator() {
  25. def cluster_json = new File('/var/lib/jenkins/workspace/qa.provision.create_pinpoint_cluster/cluster.json')
  26. def jsonSlurper1 = new JsonSlurper()
  27. def kaktus1 = jsonSlurper1.parseText(cluster_json.text)
  28. jsonSlurper1 = null
  29. keyz = kaktus1.keySet() as String[]
  30. kaktus1_size = kaktus1.size()
  31. kaktus1 = null
  32. def branches = [:]
  33. all_created_instances = []
  34. for(int i = 0; i < kaktus1_size; i++) {
  35. def cluster_json1 = new File('/var/lib/jenkins/workspace/qa.provision.create_pinpoint_cluster/cluster.json')
  36. def jsonSlurper = new JsonSlurper()
  37. def kaktus = jsonSlurper.parseText(cluster_json1.text)
  38. jsonSlurper = null
  39. env.component_name = keyz[i]
  40. env.number_of_instances = kaktus[keyz[i]].number_of_instances
  41. env.instance_type = kaktus[keyz[i]].instance_type
  42. kaktus = null
  43. provisionInstances()
  44. }
  45. println "all instances created are: " + all_created_instances
  46. }
  47.  
  48. node: {
  49. iterator()
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement