Test kernel trigger generation
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Tue, 17 Mar 2015 21:53:24 +0000 (17:53 -0400)
committerJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Tue, 17 Mar 2015 21:53:24 +0000 (17:53 -0400)
dsl/kernel-lttng-modules.seed.groovy

index 0cc04632b732ab00d78cf7627ddba67dd746b622..9e6dcbf5f16297b99c409cd7b4d116d518310de8 100644 (file)
@@ -155,7 +155,7 @@ if ( result.exitValue() == 0 ) {
     }
 
     String modulesPrefix = "lttng-modules"
-    String kernelPrefix = "kernel"
+    String kernelPrefix = "dsl-kernel"
     String separator = "-"
     // Actual job creation
     for (int i = cutoffPos; i < versions.size() ; i++) {
@@ -232,4 +232,58 @@ if ( result.exitValue() == 0 ) {
             }
         }
     }
+
+    // Trigger generations
+    def dslTriggerKernel = """\
+
+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 = ${kernelPrefix}
+
+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}
+            }
+        }
+
+    }
+
 }
This page took 0.024925 seconds and 4 git commands to generate.