-
Bug
-
Resolution: Unresolved
-
Major
-
RHEL 6
We have a job setup to build pull request branches based on a naming convention on the branches. The branch specifier is /pr/. We have 'Execute concurrent builds if necessary' turned on for this job and sometimes Jenkins will kick off 4-5 builds for the same branch at the same time and fill up the executors. I've tried adding a quiet period but that didn't seem to help.
- relates to
-
JENKINS-19022 GIT Plugin (any version) heavily bloats memory use and size of build.xml with "BuildData" fields
-
- Open
-
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
{ return; }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)
def gitRevision = build.environment['GIT_COMMIT']
{ println "build for revision $gitRevision already in progress, ABORTING..." build.executor.interrupt() }println "${build.state} - building: ${build.building}"
if (build.number != currentBuild.number && gitRevision == currentBuild.environment['GIT_COMMIT'])
}
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.