Commit aa27a1e0 authored by Clement Bois's avatar Clement Bois Committed by Pierre Smeyers
Browse files

fix: allow to override domain during blue-green deploy

parent 72d658db
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -394,6 +394,7 @@ Here are variables supported to configure review environments:
| `review-route-path` / `CF_REVIEW_ROUTE_PATH`                 | CF route path for `review` env                                                    | `$CF_DEFAULT_ROUTE_PATH`                                                           |
| `review-push-args` / `CF_REVIEW_PUSH_ARGS`                   | Additional arguments for push command                                             | `$CF_DEFAULT_PUSH_ARGS`                                                            |
| `review-retired-app-suffix` / `CF_REVIEW_RETIRED_APP_SUFFIX` | If set, the app old version is not deleted/overriden but renamed with this suffix | _none_                                                                             |
| `review-domain-tmp` / `CF_REVIEW_DOMAIN_TMP`                 | The review environment domain for the temporary blue-green app                                                        | `$CF_REVIEW_DOMAIN`                                                               |

### Integration environment configuration

@@ -418,6 +419,7 @@ Here are variables supported to configure the integration environment:
| `integ-zerodowntime` / `CF_INTEG_ZERODOWNTIME`             | Enables zero-downtime deployment on `integration` env                                                                                                                                                                                                  | `false`                             |
| `integ-environment-url` / `CF_INTEG_ENVIRONMENT_URL`       | The integration environment url **including scheme** (ex: `https://my-application-integration.nonpublic.domain.com`). Do not use variable inside variable definition as it will result in a two level cascade variable and gitlab does not allow that. | _none_                              |
| `integ-retired-app-suffix` / `CF_INTEG_RETIRED_APP_SUFFIX` | If set, the app old version is not deleted/overriden but renamed with this suffix                                                                                                                                                                      | _none_                              |
| `integ-domain-tmp` / `CF_INTEG_DOMAIN_TMP`                 | The integration environment domain for the temporary blue-green app                                                        | `$CF_INTEG_DOMAIN`                                                               |

### Staging environment configuration

@@ -443,6 +445,7 @@ Here are variables supported to configure the staging environment:
| `staging-zerodowntime` / `CF_STAGING_ZERODOWNTIME`             | Enables zero-downtime deployment on `staging` env                                                                                                                                                                                              | `false`                         |
| `staging-environment-url` / `CF_STAGING_ENVIRONMENT_URL`       | The staging environment url **including scheme** (ex: `https://my-application-staging.nonpublic.domain.com`). Do not use variable inside variable definition as it will result in a two level cascade variable and gitlab does not allow that. | _none_                          |
| `staging-retired-app-suffix` / `CF_STAGING_RETIRED_APP_SUFFIX` | If set, the app old version is not deleted/overriden but renamed with this suffix                                                                                                                                                              | _none_                          |
| `staging-domain-tmp` / `CF_STAGING_DOMAIN_TMP`                 | The staging environment domain for the temporary blue-green app                                                        | `$CF_STAGING_DOMAIN`                                                               |

### Production environment configuration

@@ -468,6 +471,7 @@ Here are variables supported to configure the production environment:
| `prod-zerodowntime` / `CF_PROD_ZERODOWNTIME`             | Enables zero-downtime deployment on `production` env                                                                                                                                                                                   | `true`                   |
| `prod-environment-url` / `CF_PROD_ENVIRONMENT_URL`       |  The production environment url **including scheme** (ex: `https://my-application.public.domain.com`) Do not use variable inside variable definition as it will result in a two level cascade variable and gitlab does not allow that. | _none_                   |
| `prod-retired-app-suffix` / `CF_PROD_RETIRED_APP_SUFFIX` | If set, the app old version is not deleted/overriden but renamed with this suffix                                                                                                                                                      | _none_                   |
| `prod-domain-tmp` / `CF_PROD_DOMAIN_TMP`                 | The production environment domain for the temporary blue-green app                                                        | `$CF_PROD_DOMAIN`                                                               |

### `cf-cleanup-all-review` job

+20 −0
Original line number Diff line number Diff line
@@ -126,6 +126,11 @@
          "description": "The review environment additional cf push arguments",
          "advanced": true
        },
        {
          "name": "CF_REVIEW_DOMAIN_TMP",
          "description": "The review environment domain for the temporary blue-green app",
          "advanced": true
        },
        {
          "name": "CF_REVIEW_ZERODOWNTIME",
          "type": "boolean",
@@ -200,6 +205,11 @@
          "description": "The integration environment additional cf push arguments",
          "advanced": true
        },
        {
          "name": "CF_INTEG_DOMAIN_TMP",
          "description": "The integration environment domain for the temporary blue-green app",
          "advanced": true
        },
        {
          "name": "CF_INTEG_ENVIRONMENT_URL",
          "type": "url",
@@ -274,6 +284,11 @@
          "description": "The staging environment additional cf push arguments",
          "advanced": true
        },
        {
          "name": "CF_STAGING_DOMAIN_TMP",
          "description": "The staging environment domain for the temporary blue-green app",
          "advanced": true
        },
        {
          "name": "CF_STAGING_ENVIRONMENT_URL",
          "type": "url",
@@ -348,6 +363,11 @@
          "description": "The production environment additional cf push arguments",
          "advanced": true
        },
        {
          "name": "CF_PROD_DOMAIN_TMP",
          "description": "The production environment domain for the temporary blue-green app",
          "advanced": true
        },
        {
          "name": "CF_PROD_ENVIRONMENT_URL",
          "type": "url",
+24 −2
Original line number Diff line number Diff line
@@ -70,6 +70,9 @@ spec:
    review-push-args:
      description: The review environment additional cf push arguments
      default: ''
    review-domain-tmp:
      description: The review environment domain for the temporary blue-green app
      default: ''
    review-zerodowntime:
      description: Enables zero-downtime deployment on review env
      type: boolean
@@ -114,6 +117,9 @@ spec:
    integ-push-args:
      description: The integration environment additional cf push arguments
      default: ''
    integ-domain-tmp:
      description: The integration environment domain for the temporary blue-green app
      default: ''
    integ-zerodowntime:
      description: Enables zero-downtime deployment on integration env
      type: boolean
@@ -148,6 +154,9 @@ spec:
    staging-push-args:
      description: The staging environment additional cf push arguments
      default: ''
    staging-domain-tmp:
      description: The staging environment domain for the temporary blue-green app
      default: ''
    staging-zerodowntime:
      description: Enables zero-downtime deployment on staging env
      type: boolean
@@ -182,6 +191,9 @@ spec:
    prod-push-args:
      description: The production environment additional cf push arguments
      default: ''
    prod-domain-tmp:
      description: The production environment domain for the temporary blue-green app
      default: ''
    prod-zerodowntime:
      description: Enables zero-downtime deployment on production env
      type: boolean
@@ -252,6 +264,7 @@ variables:
  CF_REVIEW_HOST_NAME: $[[ inputs.review-host-name ]]
  CF_REVIEW_ROUTE_PATH: $[[ inputs.review-route-path ]]
  CF_REVIEW_PUSH_ARGS: $[[ inputs.review-push-args ]]
  CF_REVIEW_DOMAIN_TMP: $[[ inputs.review-domain-tmp ]]
  CF_REVIEW_ZERODOWNTIME: $[[ inputs.review-zerodowntime ]]
  CF_REVIEW_RETIRED_APP_SUFFIX: $[[ inputs.review-retired-app-suffix ]]
  # [optional]  CF_REVIEW_USER        : specific Cloud Foundry username in review env (defaults to $CF_USER)
@@ -268,6 +281,7 @@ variables:
  CF_INTEG_HOST_NAME: $[[ inputs.integ-host-name ]]
  CF_INTEG_ROUTE_PATH: $[[ inputs.integ-route-path ]]
  CF_INTEG_PUSH_ARGS: $[[ inputs.integ-push-args ]]
  CF_INTEG_DOMAIN_TMP: $[[ inputs.integ-domain-tmp ]]
  CF_INTEG_ZERODOWNTIME: $[[ inputs.integ-zerodowntime ]]
  CF_INTEG_RETIRED_APP_SUFFIX: $[[ inputs.integ-retired-app-suffix ]]
  CF_INTEG_ENVIRONMENT_URL: $[[ inputs.integ-environment-url ]]
@@ -282,6 +296,7 @@ variables:
  CF_STAGING_HOST_NAME: $[[ inputs.staging-host-name ]]
  CF_STAGING_ROUTE_PATH: $[[ inputs.staging-route-path ]]
  CF_STAGING_PUSH_ARGS: $[[ inputs.staging-push-args ]]
  CF_STAGING_DOMAIN_TMP: $[[ inputs.staging-domain-tmp ]]
  CF_STAGING_ZERODOWNTIME: $[[ inputs.staging-zerodowntime ]]
  CF_STAGING_RETIRED_APP_SUFFIX: $[[ inputs.staging-retired-app-suffix ]]
  CF_STAGING_ENVIRONMENT_URL: $[[ inputs.staging-environment-url ]]
@@ -296,6 +311,7 @@ variables:
  CF_PROD_HOST_NAME: $[[ inputs.prod-host-name ]]
  CF_PROD_ROUTE_PATH: $[[ inputs.prod-route-path ]]
  CF_PROD_PUSH_ARGS: $[[ inputs.prod-push-args ]]
  CF_PROD_DOMAIN_TMP: $[[ inputs.prod-domain-tmp ]]
  CF_PROD_ZERODOWNTIME: $[[ inputs.prod-zerodowntime ]]
  CF_PROD_RETIRED_APP_SUFFIX: $[[ inputs.prod-retired-app-suffix ]]
  CF_PROD_ENVIRONMENT_URL: $[[ inputs.prod-environment-url ]]
@@ -752,6 +768,7 @@ stages:
    domain_target=$4
    vroute_path=$5
    push_args=$6
    domain_tmp=$7

    # for backward compatibility
    export stage=$environment_type
@@ -759,7 +776,6 @@ stages:
    log_info "--- \\e[32mblue_green_deploy\\e[0m"
    app_tmp=${app_target}-tmp
    hostname_tmp=${hostname_target}-tmp
    domain_tmp=$(default_domain)

    # check previous version is here
    if ! app_present "$app_target"
@@ -850,6 +866,7 @@ stages:
    domain=${ENV_DOMAIN:-${CF_DEFAULT_DOMAIN:-$(default_domain)}}
    routepath=${ENV_ROUTE_PATH:-${CF_DEFAULT_ROUTE_PATH}}
    pushargs="${ENV_PUSH_ARGS:-${CF_DEFAULT_PUSH_ARGS}}"
    domain_tmp=${ENV_DOMAIN_TMP:-${domain}}

    # unset any upstream deployment env & artifacts
    rm -f cloudfoundry.env
@@ -858,7 +875,7 @@ stages:
    if [[ "$zdt" = "true" ]] && [[ "$CF_ROLLING_STRATEGY" != "true" ]]
    then
      # blue/green deploy
      blue_green_deploy "$environment_type" "$environment_name" "$hostname" "$domain" "$routepath" "$pushargs"
      blue_green_deploy "$environment_type" "$environment_name" "$hostname" "$domain" "$routepath" "$pushargs" "$domain_tmp"
    else
      # simple deploy
      simple_deploy "$environment_type" "$environment_name" "$hostname" "$domain" "$routepath" "$pushargs"
@@ -1195,6 +1212,7 @@ stages:
# @arg ENV_ROUTE_PATH: env-specific route path
# @arg ENV_HOST_NAME : env-specific application hostname to use
# @arg ENV_PUSH_ARGS : env-specific additional push command arguments
# @arg ENV_DOMAIN_TMP: env-specific domain during the -tmp app
# @arg ENV_RETIRED_APP_SUFFIX : If set, the app old version is not deleted/overriden but renamed with this suffix
.cf-deploy:
  extends: .cf-base
@@ -1275,6 +1293,7 @@ cf-review:
    ENV_HOST_NAME: "$CF_REVIEW_HOST_NAME"
    ENV_ROUTE_PATH: "$CF_REVIEW_ROUTE_PATH"
    ENV_PUSH_ARGS: "$CF_REVIEW_PUSH_ARGS"
    ENV_DOMAIN_TMP: "$CF_REVIEW_DOMAIN_TMP"
    ENV_RETIRED_APP_SUFFIX: "$CF_REVIEW_RETIRED_APP_SUFFIX"
  environment:
    name: review/$CI_COMMIT_REF_NAME
@@ -1364,6 +1383,7 @@ cf-integration:
    ENV_HOST_NAME: "$CF_INTEG_HOST_NAME"
    ENV_ROUTE_PATH: "$CF_INTEG_ROUTE_PATH"
    ENV_PUSH_ARGS: "$CF_INTEG_PUSH_ARGS"
    ENV_DOMAIN_TMP: "$CF_INTEG_DOMAIN_TMP"
    ENV_RETIRED_APP_SUFFIX: "$CF_INTEG_RETIRED_APP_SUFFIX"
  environment:
    name: integration
@@ -1393,6 +1413,7 @@ cf-staging:
    ENV_HOST_NAME: "$CF_STAGING_HOST_NAME"
    ENV_ROUTE_PATH: "$CF_STAGING_ROUTE_PATH"
    ENV_PUSH_ARGS: "$CF_STAGING_PUSH_ARGS"
    ENV_DOMAIN_TMP: "$CF_STAGING_DOMAIN_TMP"
    ENV_RETIRED_APP_SUFFIX: "$CF_STAGING_RETIRED_APP_SUFFIX"
  environment:
    name: staging
@@ -1422,6 +1443,7 @@ cf-production:
    ENV_HOST_NAME: "$CF_PROD_HOST_NAME"
    ENV_ROUTE_PATH: "$CF_PROD_ROUTE_PATH"
    ENV_PUSH_ARGS: "$CF_PROD_PUSH_ARGS"
    ENV_DOMAIN_TMP: "$CF_PROD_DOMAIN_TMP"
    ENV_RETIRED_APP_SUFFIX: "$CF_PROD_RETIRED_APP_SUFFIX"
  environment:
    name: production
+2 −0
Original line number Diff line number Diff line
@@ -128,6 +128,7 @@ function teardown() {
  ENV_APP_NAME=acme1
  ENV_HOST_NAME=my-acme-host
  ENV_DOMAIN=domain.mine
  ENV_DOMAIN_TMP=domain.intra
  run cf_deploy
  # THEN
  assert_success
@@ -174,6 +175,7 @@ function teardown() {
  ENV_APP_NAME=acme1
  ENV_HOST_NAME=my-acme-host
  ENV_DOMAIN=domain.mine
  ENV_DOMAIN_TMP=domain.intra
  run cf_deploy
  # THEN
  assert_success