Abort current build if a new build is queued
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Thu, 19 May 2016 15:48:50 +0000 (11:48 -0400)
committerJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Thu, 19 May 2016 15:48:50 +0000 (11:48 -0400)
scripts/lttng-modules/master-vanilla.groovy

index b29795717a322cb0152906de364f5ab106da550f..33c62f5424fad3888f4933b4fb05d4dae3f1d6a1 100644 (file)
@@ -127,6 +127,7 @@ def maxConcurrentBuild = build.buildVariableResolver.resolve('maxConcurrentBuild
 def kgitrepo = build.buildVariableResolver.resolve('kgitrepo')
 def kverfloor = new kVersion(build.buildVariableResolver.resolve('kverfloor'))
 def job = Hudson.instance.getJob(build.buildVariableResolver.resolve('kbuildjob'))
+def currentJobName = build.project.getFullDisplayName()
 
 // Get the out variable
 def config = new HashMap()
@@ -182,6 +183,7 @@ def allBuilds = []
 def ongoingBuild = []
 def failedRuns = []
 def isFailed = false
+def similarJobQueued = 0;
 
 // Loop while we have kernel versions remaining or jobs running
 while ( kversions.size() != 0 || ongoingBuild.size() != 0 ) {
@@ -215,6 +217,15 @@ while ( kversions.size() != 0 || ongoingBuild.size() != 0 ) {
       }
     }
 
+    // Check for queued similar job since we only want to run latest
+    // As Mathieu Desnoyers requirement
+    similarJobQueued = Hudson.instance.queue.items.count{it.task.getFullDisplayName() == currentJobName}
+    if ( similarJobQueued > 0 ) {
+        // Abort since new build is queued
+        build.setResult(hudson.model.Result.ABORTED)
+        throw new InterruptedException()
+    }
+
     def i = ongoingBuild.iterator()
     while ( i.hasNext() ) {
       currentBuild = i.next()
This page took 0.024703 seconds and 4 git commands to generate.