Skip to content

Commit

Permalink
Jenkinsfile.release: make AWS AMI replication optional
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dustymabe committed Sep 11, 2019
1 parent c5b9fb3 commit fd217e6
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 22 deletions.
17 changes: 15 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ properties([
description: 'Whether to force a rebuild'),
booleanParam(name: 'MINIMAL',
defaultValue: (official ? false : true),
description: 'Whether to only build the OSTree and qemu images')
description: 'Whether to only build the OSTree and qemu images'),
// use a string here because passing booleans via `oc start-build -e`
// is non-trivial
choice(name: 'AWS_REPLICATION',
choices: (['false'] + ['true']),
defaultValue: 'false',
description: 'Force AWS AMI replication for non-production',
required: false)
]),
buildDiscarder(logRotator(
numToKeepStr: '60',
Expand Down Expand Up @@ -305,14 +312,20 @@ podTemplate(cloud: 'openshift', label: 'coreos-assembler', yaml: pod, defaultCon

// For now, we auto-release all non-production streams builds. That
// way, we can e.g. test testing-devel AMIs easily.
//
// Since we are only running this stage for non-production (i.e. mechanical
// and development) builds we'll default to not doing AWS AMI replication.
// That can be overridden by the user setting the AWS_REPLICATION parameter
// to true, overriding the default (false).
if (official && !(params.STREAM in streams.production)) {
stage('Publish') {
// use jnlp container in our pod, which has `oc` in it already
container('jnlp') {
utils.shwrap("""
oc start-build --wait fedora-coreos-pipeline-release \
-e STREAM=${params.STREAM} \
-e VERSION=${newBuildID}
-e VERSION=${newBuildID} \
-e AWS_REPLICATION=${params.AWS_REPLICATION}
""")
}
}
Expand Down
54 changes: 34 additions & 20 deletions Jenkinsfile.release
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,19 @@ properties([
string(name: 'VERSION',
description: 'Fedora CoreOS version to release',
defaultValue: '',
trim: true)
trim: true),
// Default to true for AWS_REPLICATION because the only case
// where we are running the job by hand is when we're doing a
// production release and we want to replicate there. Defaulting
// to true means there is less opportunity for human error.
//
// use a string here because passing booleans via `oc start-build -e`
// is non-trivial
choice(name: 'AWS_REPLICATION',
choices: (['true'] + ['false']),
defaultValue: 'true',
description: 'Force AWS AMI replication',
required: false)
])
])

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

podTemplate(cloud: 'openshift', label: 'coreos-assembler', yaml: pod, defaultContainer: 'jnlp') {
node('coreos-assembler') { container('coreos-assembler') {
// Replicate the newly uploaded AMI to other regions. Intentionally
// split out from the 'Upload AWS' stage to allow for tests to be added
// at a later date before replicating said image.
//
// We have to re-run the coreos-meta-translator as aws-replicate
// only modifies the meta.json
stage('Replicate AWS AMI') {
s3_stream_dir = "${s3_bucket}/prod/streams/${params.STREAM}"
// TODO: Once buildprep supports pulling specific builds
// operate on the specific build rather than the most
// recent build
utils.shwrap("""
export AWS_CONFIG_FILE=\${AWS_FCOS_BUILDS_BOT_CONFIG}
coreos-assembler buildprep s3://${s3_stream_dir}/builds
coreos-assembler aws-replicate --build=${params.VERSION}
git clone https://github.com/coreos/fedora-coreos-releng-automation /var/tmp/fcos-releng
/var/tmp/fcos-releng/coreos-meta-translator/trans.py --workdir .
coreos-assembler buildupload --skip-builds-json s3 --acl=public-read ${s3_stream_dir}/builds
""")
if (params.AWS_REPLICATION == 'true') {
// Replicate the newly uploaded AMI to other regions. Intentionally
// split out from the 'Upload AWS' stage to allow for tests to be added
// at a later date before replicating said image.
//
// We have to re-run the coreos-meta-translator as aws-replicate
// only modifies the meta.json
stage('Replicate AWS AMI') {
s3_stream_dir = "${s3_bucket}/prod/streams/${params.STREAM}"
// TODO: Once buildprep supports pulling specific builds
// operate on the specific build rather than the most
// recent build
utils.shwrap("""
export AWS_CONFIG_FILE=\${AWS_FCOS_BUILDS_BOT_CONFIG}
coreos-assembler buildprep s3://${s3_stream_dir}/builds
coreos-assembler aws-replicate --build=${params.VERSION}
git clone https://github.com/coreos/fedora-coreos-releng-automation /var/tmp/fcos-releng
/var/tmp/fcos-releng/coreos-meta-translator/trans.py --workdir .
coreos-assembler buildupload --skip-builds-json s3 --acl=public-read ${s3_stream_dir}/builds
""")
}
}

stage('Publish') {
Expand Down

0 comments on commit fd217e6

Please sign in to comment.