Skip to content

Commit 826f95e

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 86557f5 commit 826f95e

File tree

2 files changed

+47
-22
lines changed

2 files changed

+47
-22
lines changed

Diff for: Jenkinsfile

+14-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ 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')
5864
]),
5965
buildDiscarder(logRotator(
6066
numToKeepStr: '60',
@@ -305,14 +311,20 @@ podTemplate(cloud: 'openshift', label: 'coreos-assembler', yaml: pod, defaultCon
305311

306312
// For now, we auto-release all non-production streams builds. That
307313
// way, we can e.g. test testing-devel AMIs easily.
314+
//
315+
// Since we are only running this stage for non-production (i.e. mechanical
316+
// and development) builds we'll default to not doing AWS AMI replication.
317+
// That can be overridden by the user setting the AWS_REPLICATION parameter
318+
// to true, overriding the default (false).
308319
if (official && !(params.STREAM in streams.production)) {
309320
stage('Publish') {
310321
// use jnlp container in our pod, which has `oc` in it already
311322
container('jnlp') {
312323
utils.shwrap("""
313324
oc start-build --wait fedora-coreos-pipeline-release \
314325
-e STREAM=${params.STREAM} \
315-
-e VERSION=${newBuildID}
326+
-e VERSION=${newBuildID} \
327+
-e AWS_REPLICATION=${params.AWS_REPLICATION}
316328
""")
317329
}
318330
}

Diff for: Jenkinsfile.release

+33-20
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,18 @@ 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')
2334
])
2435
])
2536

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

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

5467
stage('Publish') {

0 commit comments

Comments
 (0)