Fix
[lttng-ci.git] / dsl / kernel-lttng-modules.seed.groovy
index c908a229e4cdb1dbf1c104f33335cd5a4e044881..1f4039bc7ab73011008551855ea28071030562ad 100644 (file)
@@ -277,21 +277,61 @@ if (fail){
   throw new AbortException("Some job failed")
 }
 """
-    if (isJenkinsInstance) {
-               try{
-                       def kernel_trigger_job = hudson.model.Hudson.instance.getItem("dsl-trigger-kernel")
-                       kernel_trigger_job.delete()
-               } catch(e){
-                       println("Kernel trigger already missing")
-               }
+       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 = "JOBPREFIX"
+
+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")
+}
+"""
+    if (isJenkinsInstance) {
         freeStyleJob("dsl-trigger-kernel") {
             steps {
                 systemGroovyCommand(dslTriggerKernel)
             }
-        }
-               // Trigger the kernel build
-               kernel_trigger_job = hudson.model.Hudson.instance.getItem("dsl-trigger-kernel")
-               kernel_trigger_job.scheduleBuild2(0)
+               }
+
+               modulesBranches.each { branch ->
+                       freeStyleJob("dsl-trigger-module-${branch}") {
+                               steps {
+                                       systemGroovyCommand(dslTriggerModule.replaceAll("JOBPREFIX",modulesPrefix + separator + branch + separator))
+                               }
+                       }
+               }
     }
 }
This page took 0.022912 seconds and 4 git commands to generate.