Skip to content

Commit fd217e6

Browse files
committed
Jenkinsfile.release: make AWS AMI replication optional
And default to true, but make the pipeline default to not replicate for non-production streams. We use strings and not boolean parameters because passing booleans via `oc start-build -e` is non-trivial.
1 parent c5b9fb3 commit fd217e6

File tree

2 files changed

+49
-22
lines changed

2 files changed

+49
-22
lines changed

Jenkinsfile

+15-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ properties([
5454
description: 'Whether to force a rebuild'),
5555
booleanParam(name: 'MINIMAL',
5656
defaultValue: (official ? false : true),
57-
description: 'Whether to only build the OSTree and qemu images')
57+
description: 'Whether to only build the OSTree and qemu images'),
58+
// use a string here because passing booleans via `oc start-build -e`
59+
// is non-trivial
60+
choice(name: 'AWS_REPLICATION',
61+
choices: (['false'] + ['true']),
62+
defaultValue: 'false',
63+
description: 'Force AWS AMI replication for non-production',
64+
required: false)
5865
]),
5966
buildDiscarder(logRotator(
6067
numToKeepStr: '60',
@@ -305,14 +312,20 @@ podTemplate(cloud: 'openshift', label: 'coreos-assembler', yaml: pod, defaultCon
305312

306313
// For now, we auto-release all non-production streams builds. That
307314
// way, we can e.g. test testing-devel AMIs easily.
315+
//
316+
// Since we are only running this stage for non-production (i.e. mechanical
317+
// and development) builds we'll default to not doing AWS AMI replication.
318+
// That can be overridden by the user setting the AWS_REPLICATION parameter
319+
// to true, overriding the default (false).
308320
if (official && !(params.STREAM in streams.production)) {
309321
stage('Publish') {
310322
// use jnlp container in our pod, which has `oc` in it already
311323
container('jnlp') {
312324
utils.shwrap("""
313325
oc start-build --wait fedora-coreos-pipeline-release \
314326
-e STREAM=${params.STREAM} \
315-
-e VERSION=${newBuildID}
327+
-e VERSION=${newBuildID} \
328+
-e AWS_REPLICATION=${params.AWS_REPLICATION}
316329
""")
317330
}
318331
}

Jenkinsfile.release

+34-20
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,19 @@ properties([
1919
string(name: 'VERSION',
2020
description: 'Fedora CoreOS version to release',
2121
defaultValue: '',
22-
trim: true)
22+
trim: true),
23+
// Default to true for AWS_REPLICATION because the only case
24+
// where we are running the job by hand is when we're doing a
25+
// production release and we want to replicate there. Defaulting
26+
// to true means there is less opportunity for human error.
27+
//
28+
// use a string here because passing booleans via `oc start-build -e`
29+
// is non-trivial
30+
choice(name: 'AWS_REPLICATION',
31+
choices: (['true'] + ['false']),
32+
defaultValue: 'true',
33+
description: 'Force AWS AMI replication',
34+
required: false)
2335
])
2436
])
2537

@@ -30,25 +42,27 @@ pod = pod.replace("COREOS_ASSEMBLER_IMAGE", "coreos-assembler:master")
3042

3143
podTemplate(cloud: 'openshift', label: 'coreos-assembler', yaml: pod, defaultContainer: 'jnlp') {
3244
node('coreos-assembler') { container('coreos-assembler') {
33-
// Replicate the newly uploaded AMI to other regions. Intentionally
34-
// split out from the 'Upload AWS' stage to allow for tests to be added
35-
// at a later date before replicating said image.
36-
//
37-
// We have to re-run the coreos-meta-translator as aws-replicate
38-
// only modifies the meta.json
39-
stage('Replicate AWS AMI') {
40-
s3_stream_dir = "${s3_bucket}/prod/streams/${params.STREAM}"
41-
// TODO: Once buildprep supports pulling specific builds
42-
// operate on the specific build rather than the most
43-
// recent build
44-
utils.shwrap("""
45-
export AWS_CONFIG_FILE=\${AWS_FCOS_BUILDS_BOT_CONFIG}
46-
coreos-assembler buildprep s3://${s3_stream_dir}/builds
47-
coreos-assembler aws-replicate --build=${params.VERSION}
48-
git clone https://github.com/coreos/fedora-coreos-releng-automation /var/tmp/fcos-releng
49-
/var/tmp/fcos-releng/coreos-meta-translator/trans.py --workdir .
50-
coreos-assembler buildupload --skip-builds-json s3 --acl=public-read ${s3_stream_dir}/builds
51-
""")
45+
if (params.AWS_REPLICATION == 'true') {
46+
// Replicate the newly uploaded AMI to other regions. Intentionally
47+
// split out from the 'Upload AWS' stage to allow for tests to be added
48+
// at a later date before replicating said image.
49+
//
50+
// We have to re-run the coreos-meta-translator as aws-replicate
51+
// only modifies the meta.json
52+
stage('Replicate AWS AMI') {
53+
s3_stream_dir = "${s3_bucket}/prod/streams/${params.STREAM}"
54+
// TODO: Once buildprep supports pulling specific builds
55+
// operate on the specific build rather than the most
56+
// recent build
57+
utils.shwrap("""
58+
export AWS_CONFIG_FILE=\${AWS_FCOS_BUILDS_BOT_CONFIG}
59+
coreos-assembler buildprep s3://${s3_stream_dir}/builds
60+
coreos-assembler aws-replicate --build=${params.VERSION}
61+
git clone https://github.com/coreos/fedora-coreos-releng-automation /var/tmp/fcos-releng
62+
/var/tmp/fcos-releng/coreos-meta-translator/trans.py --workdir .
63+
coreos-assembler buildupload --skip-builds-json s3 --acl=public-read ${s3_stream_dir}/builds
64+
""")
65+
}
5266
}
5367

5468
stage('Publish') {

0 commit comments

Comments
 (0)