From bdb6883d1623a680f8f0085df334df4bda9b3434 Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Wed, 25 Apr 2018 15:56:53 -0500 Subject: [PATCH 1/3] Use variables to support staging for deployments - Changes 'staging' job to be always defined and to be enable only when $STAGING_ENABLED is defined. - Changes 'production' job to be enable except when $STAGING_ENABLED is defined. - Creates a new job 'production_manual' based on 'production' but manually defined Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/38549 --- Auto-DevOps.gitlab-ci.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Auto-DevOps.gitlab-ci.yml b/Auto-DevOps.gitlab-ci.yml index b8a9d8d..5c32f6d 100644 --- a/Auto-DevOps.gitlab-ci.yml +++ b/Auto-DevOps.gitlab-ci.yml @@ -217,7 +217,7 @@ stop_review: # only manually promote to production, enable this job by removing the dot (.), # and uncomment the `when: manual` line in the `production` job. -.staging: +staging: stage: staging script: - check_kube_domain @@ -234,6 +234,8 @@ stop_review: refs: - master kubernetes: active + variables: + - $STAGING_ENABLED # Canaries are disabled by default, but if you want them, # and know what the downsides are, enable this job by removing the dot (.), @@ -263,7 +265,7 @@ stop_review: # or `canary` deploys, or you simply want more control over when you deploy # to production, uncomment the `when: manual` line in the `production` job. -production: +production: &production stage: production script: - check_kube_domain @@ -285,6 +287,13 @@ production: refs: - master kubernetes: active + except: + variables: + - $STAGING_ENABLED + +production_manual: + <<: *production + when: manual # --------------------------------------------------------------------------- -- 2.22.0 From a7e18757175876f0ae772291b3ed215310fae4ce Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Tue, 1 May 2018 11:41:35 -0500 Subject: [PATCH 2/3] Changes the production, staging and production_manual configuration - Production is not-manual, used when STAGING_ENABLED is not set - Staging is not-manual, used when STAGING_ENABLED is set - Production_manual is manual, used when STAGING_ENABLED is set --- Auto-DevOps.gitlab-ci.yml | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/Auto-DevOps.gitlab-ci.yml b/Auto-DevOps.gitlab-ci.yml index 5c32f6d..c041b1a 100644 --- a/Auto-DevOps.gitlab-ci.yml +++ b/Auto-DevOps.gitlab-ci.yml @@ -265,7 +265,7 @@ staging: # or `canary` deploys, or you simply want more control over when you deploy # to production, uncomment the `when: manual` line in the `production` job. -production: &production +production: stage: production script: - check_kube_domain @@ -282,7 +282,6 @@ production: &production url: http://$CI_PROJECT_PATH_SLUG.$AUTO_DEVOPS_DOMAIN artifacts: paths: [environment_url.txt] -# when: manual only: refs: - master @@ -291,9 +290,30 @@ production: &production variables: - $STAGING_ENABLED -production_manual: - <<: *production +production_manual: + stage: production + script: + - check_kube_domain + - install_dependencies + - download_chart + - ensure_namespace + - install_tiller + - create_secret + - deploy + - delete canary + - persist_environment_url + environment: + name: production + url: http://$CI_PROJECT_PATH_SLUG.$AUTO_DEVOPS_DOMAIN + artifacts: + paths: [environment_url.txt] when: manual + only: + refs: + - master + kubernetes: active + variables: + - $STAGING_ENABLED # --------------------------------------------------------------------------- -- 2.22.0 From 6dffbec1b1eb30f4ea772256720eadc08fce5a55 Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Tue, 1 May 2018 15:12:28 -0500 Subject: [PATCH 3/3] Refactor production job to remove duplication --- Auto-DevOps.gitlab-ci.yml | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/Auto-DevOps.gitlab-ci.yml b/Auto-DevOps.gitlab-ci.yml index c041b1a..822a23a 100644 --- a/Auto-DevOps.gitlab-ci.yml +++ b/Auto-DevOps.gitlab-ci.yml @@ -265,7 +265,7 @@ staging: # or `canary` deploys, or you simply want more control over when you deploy # to production, uncomment the `when: manual` line in the `production` job. -production: +.production: &production_template stage: production script: - check_kube_domain @@ -282,6 +282,9 @@ production: url: http://$CI_PROJECT_PATH_SLUG.$AUTO_DEVOPS_DOMAIN artifacts: paths: [environment_url.txt] + +production: + <<: *production_template only: refs: - master @@ -290,23 +293,8 @@ production: variables: - $STAGING_ENABLED -production_manual: - stage: production - script: - - check_kube_domain - - install_dependencies - - download_chart - - ensure_namespace - - install_tiller - - create_secret - - deploy - - delete canary - - persist_environment_url - environment: - name: production - url: http://$CI_PROJECT_PATH_SLUG.$AUTO_DEVOPS_DOMAIN - artifacts: - paths: [environment_url.txt] +production_manual: + <<: *production_template when: manual only: refs: -- 2.22.0