From 6fe9cced3ee550f7f3a77143d2c3ee4adee376cd Mon Sep 17 00:00:00 2001 From: Weimin Yu Date: Wed, 30 Oct 2019 13:58:56 -0400 Subject: [PATCH] Save current deployment tag for every environment (#332) * Save release tag during deployment * Save current tag for every environment Store tag of the current deployment in each environment. This is used by the server-sql compatibility test. * Save current tag for every environment Store tag of the current deployment in each environment. This is used by the server-sql compatibility test. --- release/cloudbuild-deploy.yaml | 15 +++++++++++++-- release/cloudbuild-nomulus.yaml | 6 ++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/release/cloudbuild-deploy.yaml b/release/cloudbuild-deploy.yaml index 1faa01980..50ba7d68c 100644 --- a/release/cloudbuild-deploy.yaml +++ b/release/cloudbuild-deploy.yaml @@ -1,13 +1,13 @@ # To run the build locally, install cloud-build-local first. # Then run: -# cloud-build-local --config=cloudbuild-deploy-beam.yaml --dryrun=false \ +# cloud-build-local --config=cloudbuild-deploy.yaml --dryrun=false \ # --substitutions=TAG_NAME=[TAG],_ENV=[ENV] .. # # This will deploy Beam pipelines to GCS for the PROJECT_ID defined in gcloud # tool. # # To manually trigger a build on GCB, run: -# gcloud builds submit --config=cloudbuild-deploy-beam.yaml \ +# gcloud builds submit --config=cloudbuild-deploy.yaml \ # --substitutions=TAG_NAME=[TAG],_ENV=[ENV] .. # # To trigger a build automatically, follow the instructions below and add a trigger: @@ -46,6 +46,17 @@ steps: - --credential - tool-credential.json - deploy_invoicing_pipeline +# Save the deployed tag for the current environment on GCS. Because of b/137891685 +# which causes the for-loop in the next step to fail, this may not be the last step. +# TODO(weiminyu): do this in last step, and use 'artifacts' section to upload the tag. +- name: 'gcr.io/${PROJECT_ID}/builder:latest' + entrypoint: /bin/bash + args: + - -c + - | + set -e + echo ${TAG_NAME} | \ + gsutil cp - gs://${PROJECT_ID}-deploy/deployed_tags/nomulus.${_ENV}.tag # Deploy the GAE config files. # First authorize the gcloud tool to use the credential json file, then # download and unzip the tarball that contains the relevant config files diff --git a/release/cloudbuild-nomulus.yaml b/release/cloudbuild-nomulus.yaml index df152d9b9..8f274374e 100644 --- a/release/cloudbuild-nomulus.yaml +++ b/release/cloudbuild-nomulus.yaml @@ -25,6 +25,11 @@ steps: # Build the tool binary and image. - name: 'gcr.io/${PROJECT_ID}/builder:latest' args: ['release/build_nomulus_for_env.sh', 'tool', 'output'] +# Save TAG_NAME in ./output/tag_name, to be uploaded later. This file is purely +# informational. It makes it easier to tell the tag of the current 'live' release. +- name: 'gcr.io/${PROJECT_ID}/builder:latest' + entrypoint: /bin/bash + args: [ '-c', 'echo ${TAG_NAME} > output/tag_name'] # Tag the tool image and push it to the registry. - name: 'gcr.io/${PROJECT_ID}/builder:latest' entrypoint: /bin/bash @@ -66,6 +71,7 @@ artifacts: location: 'gs://${PROJECT_ID}-deploy/${TAG_NAME}' paths: - 'output/*.tar' + - 'output/tag_name' - 'output/nomulus.jar' - 'release/cloudbuild-tag.yaml' - 'release/cloudbuild-sync.yaml'