Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jenkinsfile.release: make AWS AMI replication optional #132

Merged
merged 1 commit into from
Sep 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ 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')
]),
buildDiscarder(logRotator(
numToKeepStr: '60',
Expand Down Expand Up @@ -305,14 +311,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).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor/optional: seems like this would belong better near the default: 'false' line?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

going to leave it where it is for now. I know it's just comments, but I don't want to re-test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err rather I don't have the ability to re-test right now.

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
53 changes: 33 additions & 20 deletions Jenkinsfile.release
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,18 @@ 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')
])
])

Expand All @@ -30,25 +41,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