Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hudson.model.*
- def scedule(items) {
- items.collect {
- job = Hudson.instance.getJob(it.name)
- paramsAction = new ParametersAction(it.params)
- causeAction = new CauseAction(new Cause.UpstreamCause(Thread.currentThread().executable))
- Hudson.instance.queue.schedule(job, 0, causeAction, paramsAction)
- }
- }
- def waitforstart(items) {
- items.collect { it.getFuture().waitForStart() }
- }
- def waitforend(items, delay=1) {
- while(items.any { it.isBuilding() || it.isInProgress() }) {
- sleep(delay*1000)
- }
- items
- }
- jobs = []
- jobs.add([
- name:'test1',
- params:[]
- ])
- jobs.add([
- name:'test2',
- params: []
- ])
- items = scedule(jobs)
- items.each{ println("Trigger ${it.getUrl()}") }
- items = waitforstart(items)
- items.each{ println("Build ${it.getUrl()}") }
- items = waitforend(items)
- items.each{ println("${it.getUrl()} ${it.getBuildStatusSummary().message }") }
- Thread.currentThread().executable.result = items.max { it.result.ordinal }.result
Add Comment
Please, Sign In to add comment