Skip to content

Commit f9f9cc1

Browse files
committed
jobs/build: lock buildfetch to avoid simultaneous jobs race condition
fixes: #1079
1 parent b976b70 commit f9f9cc1

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

jobs/build.Jenkinsfile

+14-13
Original file line numberDiff line numberDiff line change
@@ -225,26 +225,27 @@ lock(resource: "build-${params.STREAM}") {
225225
}
226226

227227
// buildfetch previous build info
228-
stage('BuildFetch') {
229-
if (s3_stream_dir) {
230-
pipeutils.shwrapWithAWSBuildUploadCredentials("""
231-
cosa buildfetch --arch=${basearch} \
232-
--url s3://${s3_stream_dir}/builds \
233-
--aws-config-file \${AWS_BUILD_UPLOAD_CONFIG}
234-
""")
235-
if (parent_version != "") {
236-
// also fetch the parent version; this is used by cosa to do the diff
228+
lock(resource: "build-${params.STREAM}") {
229+
stage('BuildFetch') {
230+
if (s3_stream_dir) {
237231
pipeutils.shwrapWithAWSBuildUploadCredentials("""
238232
cosa buildfetch --arch=${basearch} \
239-
--build ${parent_version} \
240233
--url s3://${s3_stream_dir}/builds \
241234
--aws-config-file \${AWS_BUILD_UPLOAD_CONFIG}
242235
""")
236+
if (parent_version != "") {
237+
// also fetch the parent version; this is used by cosa to do the diff
238+
pipeutils.shwrapWithAWSBuildUploadCredentials("""
239+
cosa buildfetch --arch=${basearch} \
240+
--build ${parent_version} \
241+
--url s3://${s3_stream_dir}/builds \
242+
--aws-config-file \${AWS_BUILD_UPLOAD_CONFIG}
243+
""")
244+
}
243245
}
244246
}
245247
}
246248

247-
248249
def prevBuildID = null
249250
if (utils.pathExists("builds/latest")) {
250251
prevBuildID = shwrapCapture("readlink builds/latest")
@@ -259,7 +260,7 @@ lock(resource: "build-${params.STREAM}") {
259260
shwrap("python3 /usr/lib/coreos-assembler/download-overrides.py")
260261
overrides_fetch_param = "--with-cosa-overrides"
261262
}
262-
shwrap("cosa fetch ${overrides_fetch_param} ${strict_build_param}")
263+
shwrap("cosa fetch ${overrides_fetch_param} ${strict_build_param}")
263264
}
264265

265266
stage('Build OSTree') {
@@ -592,7 +593,7 @@ def run_release_job(buildID) {
592593

593594
def buildid_has_work_pending(buildID, arches) {
594595
def locked = true
595-
// these locks match the ones in the release job
596+
// these locks match the ones in the release job
596597
def locks = arches.collect{[resource: "release-${buildID}-${it}"]}
597598
lock(resource: "release-${params.STREAM}", extra: locks, skipIfLocked: true) {
598599
// NB: `return` here wouldn't actually return from the function

0 commit comments

Comments
 (0)