generate poll trigger
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Mon, 27 Apr 2015 22:56:29 +0000 (18:56 -0400)
committerJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Mon, 27 Apr 2015 22:56:29 +0000 (18:56 -0400)
dsl/kernel-lttng-modules.seed.groovy

index 749d13106b2e45a5195de93fa4da2e8774da729d..608282fd690ff513dbc570db62a41f43831c8a8b 100644 (file)
@@ -273,6 +273,48 @@ jobs.each { job ->
   }
 }
 
+if (fail){
+  throw new AbortException("Some job failed")
+}
+"""
+       def dslTriggerModule = """\
+import hudson.model.*
+import hudson.AbortException
+import hudson.console.HyperlinkNote
+import java.util.concurrent.CancellationException
+
+
+def jobs = hudson.model.Hudson.instance.items
+def fail = false
+def jobStartWith = "${modulesPrefix + separator}%1$s"
+
+def anotherBuild
+jobs.each { job ->
+  def jobName = job.getName()
+  if (jobName.startsWith(jobStartWith)) {
+    def lastBuild = job.getLastBuild()
+    if (lastBuild == null) {
+      try {
+        def future = job.scheduleBuild2(0, new Cause.UpstreamCause(build))
+        println "\\tWaiting for the completion of " + HyperlinkNote.encodeTo('/' + job.url, job.fullDisplayName)
+        anotherBuild = future.get()
+      } catch (CancellationException x) {
+        throw new AbortException("\${job.fullDisplayName} aborted.")
+      }
+      println HyperlinkNote.encodeTo('/' + anotherBuild.url, anotherBuild.fullDisplayName) + " completed. Result was " + anotherBuild.result
+
+      build.result = anotherBuild.result
+      if (anotherBuild.result != Result.SUCCESS && anotherBuild.result != Result.UNSTABLE) {
+        // We abort this build right here and now.
+        fail = true
+        println("Build Failed")
+      }
+    } else {
+      println("\\tAlready built")
+    }
+  }
+}
+
 if (fail){
   throw new AbortException("Some job failed")
 }
@@ -282,6 +324,14 @@ if (fail){
             steps {
                 systemGroovyCommand(dslTriggerKernel)
             }
-        }
+               }
+
+               modulesBranches.each { branch ->
+                       freeStyleJob("dsl-trigger-module-${branch}") {
+                               steps {
+                                       systemGroovyCommand(snprintf(dslTriggerModule,[branch]))
+                               }
+                       }
+               }
     }
 }
This page took 0.023481 seconds and 4 git commands to generate.