The hacky workaround I'm using that basically works (some side-effects but those are tolerable for us for now):

Add this groovy script as a build pre-step:

println "checking for duplicate builds"

// get current thread / Executor
def thr = Thread.currentThread()
// get current build
def currentBuild = thr?.executable
def build = currentBuild.previousBuild
for(i in 0..10) {
if (build == null || !build.building) { return; }
def gitRevision = build.environment['GIT_COMMIT']
println "${build.state} - building: ${build.building}"
if (build.number != currentBuild.number && gitRevision == currentBuild.environment['GIT_COMMIT']) { println "build for revision $gitRevision already in progress, ABORTING..." build.executor.interrupt() }
}

This basically will at the start of a build look for already in-progress builds for a given revision and cancel it. You could allow the older build to "win" but we needed the newer one to win because we're using Stash for pull requests and needed the newer build so that Stash knows the build was successful.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

--
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to