- println(moduleJobName)
-
- // Jenkins only dsl
- if (isJenkinsInstance) {
- matrixJob("${jobName}") {
- using("linux-master")
- scm {
- git {
- remote {
- url("${linuxURL}")
- }
- branch(versions[i].gitRefs)
- shallowClone(true)
- relativeTargetDir(linuxCheckoutTo)
- reference(linuxGitReference)
- }
- }
- publishers {
- downstream(moduleJobName, 'SUCCESS')
- }
- }
- // Corresponding Module job
- matrixJob("${moduleJobName}") {
- using("modules")
- multiscm {
- git {
- remote {
- name("linux")
- url("${linuxURL}")
- }
- branch(versions[i].gitRefs)
- shallowClone(true)
- relativeTargetDir(linuxCheckoutTo)
- reference(linuxGitReference)
- }
- git {
- remote {
- name("lttng-modules")
- url(modulesURL)
- }
- branch("master")
- relativeTargetDir(modulesCheckoutTo)
- }
- }
- steps {
- copyArtifacts("${jobName}/arch=\$arch", "linux-artifact/**", '', false, false) {
- latestSuccessful(true) // Latest successful build
- }
- shell(readFileFromWorkspace('lttng-modules/lttng-modules-dsl-master.sh'))
- }
- }
- }
- }
- }
+ if (isJenkinsInstance) {
+ matrixJob("${jobName}") {
+ using("linux-master")
+ scm {
+ git {
+ remote {
+ url("${linuxURL}")
+ }
+ branch(versions[i].gitRefs)
+ shallowClone(true)
+ relativeTargetDir(linuxCheckoutTo)
+ reference(linuxGitReference)
+ }
+ }
+ publishers {
+ modulesJob.each {
+ downstream(it.value, 'SUCCESS')
+ }
+ }
+ }
+ }
+ // Corresponding Module job
+ modulesJob.each { job ->
+ println("\t" + job.key + " " + job.value)
+ if (isJenkinsInstance) {
+ matrixJob(job.value) {
+ using("modules")
+ multiscm {
+ git {
+ remote {
+ name(kernelPrefix)
+ url("${linuxURL}")
+ }
+ branch(versions[i].gitRefs)
+ shallowClone(true)
+ relativeTargetDir(linuxCheckoutTo)
+ reference(linuxGitReference)
+ }
+ git {
+ remote {
+ name(modulesPrefix)
+ url(modulesURL)
+ }
+ branch(job.key)
+ relativeTargetDir(modulesCheckoutTo)
+ }
+ }
+ steps {
+ copyArtifacts("${jobName}/arch=\$arch", "linux-artifact/**", '', false, false) {
+ latestSuccessful(true) // Latest successful build
+ }
+ shell(readFileFromWorkspace('lttng-modules/lttng-modules-dsl-master.sh'))
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // 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)
+ }
+ }
+ // Trigger the kernel build
+ def kernel_trigger_job = hudson.model.Hudson.instance.getItem("dsl-trigger-kernel")
+ kernel_trigger_job.scheduleBuild2(0)
+ }