From b9d3a047c887f44b1522bef5f56f7f8886fc7695 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Thu, 23 Feb 2023 15:41:29 -0500 Subject: [PATCH] jobs/build: don't start new build until previous build completes Since 973bcf9 ("jobs/build: rerun `build-arch` if previous build is incomplete"), there is a race possible where the `build` job rerun logic could kick in before the `release` jobs initially triggered for that build has finished. We don't want to queue builds in that case. Let's just prevent starting up the build job at all if there are remaining pieces from another build for this stream running. --- jobs/build.Jenkinsfile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/jobs/build.Jenkinsfile b/jobs/build.Jenkinsfile index 02d2cb359..1308932ee 100644 --- a/jobs/build.Jenkinsfile +++ b/jobs/build.Jenkinsfile @@ -121,6 +121,15 @@ if (params.WAIT_FOR_RELEASE_JOB) { timeout_mins += timeout_mins + 30 } +// Before proceeding let's make sure no jobs for this stream are currently +// running. This includes multi-arch jobs and release jobs. +echo "Waiting for a clear runway for ${params.STREAM}" +def locks = additional_arches.collect{[resource: "build-${params.STREAM}-${it}"]} +locks += [resource: "release-${params.STREAM}"] +lock(resource: "build-${params.STREAM}", extra: locks) { + echo "The runway is clear for ${params.STREAM}" +} + lock(resource: "build-${params.STREAM}") { timeout(time: timeout_mins, unit: 'MINUTES') { cosaPod(cpu: "${ncpus}",