From: Jonathan Rajotte Date: Thu, 19 May 2016 15:58:26 +0000 (-0400) Subject: Abort modules build if a new build is queued X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=bcf4d9d08d2dcad7201ab739a328fe2b6210720b;p=lttng-ci.git Abort modules build if a new build is queued --- diff --git a/scripts/lttng-modules/master-rt.groovy b/scripts/lttng-modules/master-rt.groovy index 3b84c1a..9d11387 100644 --- a/scripts/lttng-modules/master-rt.groovy +++ b/scripts/lttng-modules/master-rt.groovy @@ -120,6 +120,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() @@ -197,6 +198,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() diff --git a/scripts/lttng-modules/master-ubuntu.groovy b/scripts/lttng-modules/master-ubuntu.groovy index 1909d48..9f1869f 100644 --- a/scripts/lttng-modules/master-ubuntu.groovy +++ b/scripts/lttng-modules/master-ubuntu.groovy @@ -29,6 +29,7 @@ def maxConcurrentBuild = build.buildVariableResolver.resolve('maxConcurrentBuild def kgitrepo = build.buildVariableResolver.resolve('kgitrepo') def uversion = build.buildVariableResolver.resolve('uversion') def job = Hudson.instance.getJob(build.buildVariableResolver.resolve('kbuildjob')) +def currentJobName = build.project.getFullDisplayName() // Get the out variable def config = new HashMap() @@ -128,6 +129,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() diff --git a/scripts/lttng-modules/master-vanilla.groovy b/scripts/lttng-modules/master-vanilla.groovy index 33c62f5..ea3222b 100644 --- a/scripts/lttng-modules/master-vanilla.groovy +++ b/scripts/lttng-modules/master-vanilla.groovy @@ -218,7 +218,7 @@ while ( kversions.size() != 0 || ongoingBuild.size() != 0 ) { } // Check for queued similar job since we only want to run latest - // As Mathieu Desnoyers requirement + // as Mathieu Desnoyers requirement similarJobQueued = Hudson.instance.queue.items.count{it.task.getFullDisplayName() == currentJobName} if ( similarJobQueued > 0 ) { // Abort since new build is queued