Guest User

Untitled

a guest
Feb 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. import hudson.model.*
  2.  
  3. def scedule(items) {
  4. items.collect {
  5. job = Hudson.instance.getJob(it.name)
  6. paramsAction = new ParametersAction(it.params)
  7. causeAction = new CauseAction(new Cause.UpstreamCause(Thread.currentThread().executable))
  8. Hudson.instance.queue.schedule(job, 0, causeAction, paramsAction)
  9. }
  10. }
  11.  
  12. def waitforstart(items) {
  13. items.collect { it.getFuture().waitForStart() }
  14. }
  15.  
  16. def waitforend(items, delay=1) {
  17. while(items.any { it.isBuilding() || it.isInProgress() }) {
  18. sleep(delay*1000)
  19. }
  20. items
  21. }
  22.  
  23. jobs = []
  24.  
  25. jobs.add([
  26. name:'test1',
  27. params:[]
  28. ])
  29. jobs.add([
  30. name:'test2',
  31. params: []
  32. ])
  33.  
  34. items = scedule(jobs)
  35. items.each{ println("Trigger ${it.getUrl()}") }
  36. items = waitforstart(items)
  37. items.each{ println("Build ${it.getUrl()}") }
  38. items = waitforend(items)
  39. items.each{ println("${it.getUrl()} ${it.getBuildStatusSummary().message }") }
  40. Thread.currentThread().executable.result = items.max { it.result.ordinal }.result
Add Comment
Please, Sign In to add comment