Commit 6f66bf75 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

fix: variables initialized from input expression

parent 10b9f5df
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -368,7 +368,7 @@ The {{cookiecutter.template_name}} template uses some global configuration used
| `image` / `{{cookiecutter.template_PREFIX}}_IMAGE`              | the Docker image used to run {{cookiecutter.template_name}} CLI commands | `registry.hub.docker.com/{{cookiecutter.project_slug}}:latest` |
| `base-app-name` / `{{cookiecutter.template_PREFIX}}_BASE_APP_NAME`      | Base application name                  | `$CI_PROJECT_NAME` ([see GitLab doc](https://docs.gitlab.com/ee/ci/variables/predefined_variables.html)) |
| `api-url` / `{{cookiecutter.template_PREFIX}}_API_URL`            | Default {{cookiecutter.template_name}} API url | _none_ |
| `api-token` / `{{cookiecutter.template_PREFIX}}_API_TOKEN`          | Default {{cookiecutter.template_name}} API token | _none_ |
| :lock: `{{cookiecutter.template_PREFIX}}_API_TOKEN`          | Default {{cookiecutter.template_name}} API token | _none_ |
| `environment-url` / `{{cookiecutter.template_PREFIX}}_ENVIRONMENT_URL`    | Default environments url _(only define for static environment URLs declaration)_<br/>_supports late variable expansion (ex: `https://%{environment_name}.{{cookiecutter.project_slug}}.acme.com`)_ | _none_ |
| `scripts-dir` / `{{cookiecutter.template_PREFIX}}_SCRIPTS_DIR`        | Directory where deploy & cleanup scripts are located | `.` _(root project dir)_ |

@@ -386,7 +386,7 @@ Here are variables supported to configure review environments:
| `review-project` / `{{cookiecutter.template_PREFIX}}_REVIEW_PROJECT`     | Project ID for `review` env | _none_ (disabled) |
| `review-app-name` / `{{cookiecutter.template_PREFIX}}_REVIEW_APP_NAME`    | Application name for `review` env      | `"{{ '${' }}{{cookiecutter.template_PREFIX}}_BASE_APP_NAME}-${CI_ENVIRONMENT_SLUG}"` (ex: `myproject-review-fix-bug-12`) |
| `review-api-url` / `{{cookiecutter.template_PREFIX}}_REVIEW_API_URL`     | API url for `review` env _(only define to override default)_ | `${{cookiecutter.template_PREFIX}}_API_URL` |
| `review-api-token` / `{{cookiecutter.template_PREFIX}}_REVIEW_API_TOKEN`   | API token for `review` env _(only define to override default)_ | `${{cookiecutter.template_PREFIX}}_API_TOKEN` |
| :lock: `{{cookiecutter.template_PREFIX}}_REVIEW_API_TOKEN`   | API token for `review` env _(only define to override default)_ | `${{cookiecutter.template_PREFIX}}_API_TOKEN` |
| `review-environment-url` / `{{cookiecutter.template_PREFIX}}_REVIEW_ENVIRONMENT_URL`| The review environments url _(only define for static environment URLs declaration and if different from default)_ | `${{cookiecutter.template_PREFIX}}_ENVIRONMENT_URL` |
| `review-autostop-duration` / `{{cookiecutter.template_PREFIX}}_REVIEW_AUTOSTOP_DURATION`| The amount of time before GitLab will automatically stop `review` environments | `4 hours` |

@@ -403,7 +403,7 @@ Here are variables supported to configure the integration environment:
| `integ-project` / `{{cookiecutter.template_PREFIX}}_INTEG_PROJECT`      | Project ID for `integration` env | _none_ (disabled) |
| `integ-app-name` / `{{cookiecutter.template_PREFIX}}_INTEG_APP_NAME`     | Application name for `integration` env | `{{ '${' }}{{cookiecutter.template_PREFIX}}_BASE_APP_NAME}-integration` |
| `integ-api-url` / `{{cookiecutter.template_PREFIX}}_INTEG_API_URL`      | API url for `integration` env _(only define to override default)_ | `${{cookiecutter.template_PREFIX}}_API_URL` |
| `integ-api-token` / `{{cookiecutter.template_PREFIX}}_INTEG_API_TOKEN`    | API token for `integration` env _(only define to override default)_ | `${{cookiecutter.template_PREFIX}}_API_TOKEN` |
| :lock: `{{cookiecutter.template_PREFIX}}_INTEG_API_TOKEN`    | API token for `integration` env _(only define to override default)_ | `${{cookiecutter.template_PREFIX}}_API_TOKEN` |
| `integ-environment-url` / `{{cookiecutter.template_PREFIX}}_INTEG_ENVIRONMENT_URL`| The integration environment url _(only define for static environment URLs declaration and if different from default)_ | `${{cookiecutter.template_PREFIX}}_ENVIRONMENT_URL` |

### Staging environment configuration
@@ -420,7 +420,7 @@ Here are variables supported to configure the staging environment:
| `staging-project` / `{{cookiecutter.template_PREFIX}}_STAGING_PROJECT`    | Project ID for `staging` env | _none_ (disabled) |
| `staging-app-name` / `{{cookiecutter.template_PREFIX}}_STAGING_APP_NAME`   | Application name for `staging` env     | `{{ '${' }}{{cookiecutter.template_PREFIX}}_BASE_APP_NAME}-staging` |
| `staging-api-url` / `{{cookiecutter.template_PREFIX}}_STAGING_API_URL`    | API url for `staging` env _(only define to override default)_ | `${{cookiecutter.template_PREFIX}}_API_URL` |
| `staging-api-token` / `{{cookiecutter.template_PREFIX}}_STAGING_API_TOKEN`  | API token for `staging` env _(only define to override default)_ | `${{cookiecutter.template_PREFIX}}_API_TOKEN` |
| :lock: `{{cookiecutter.template_PREFIX}}_STAGING_API_TOKEN`  | API token for `staging` env _(only define to override default)_ | `${{cookiecutter.template_PREFIX}}_API_TOKEN` |
| `staging-environment-url` / `{{cookiecutter.template_PREFIX}}_STAGING_ENVIRONMENT_URL`| The staging environment url _(only define for static environment URLs declaration and if different from default)_ | `${{cookiecutter.template_PREFIX}}_ENVIRONMENT_URL` |

### Production environment configuration
@@ -436,7 +436,7 @@ Here are variables supported to configure the production environment:
| `prod-project` / `{{cookiecutter.template_PREFIX}}_PROD_PROJECT`        | Project ID for `production` env | _none_ (disabled) |
| `prod-app-name` / `{{cookiecutter.template_PREFIX}}_PROD_APP_NAME`       | Application name for `production` env  | `${{cookiecutter.template_PREFIX}}_BASE_APP_NAME` |
| `prod-api-url` / `{{cookiecutter.template_PREFIX}}_PROD_API_URL`        | API url for `production` env _(only define to override default)_ | `${{cookiecutter.template_PREFIX}}_API_URL` |
| `prod-api-token` / `{{cookiecutter.template_PREFIX}}_PROD_API_TOKEN`      | API token for `production` env _(only define to override default)_ | `${{cookiecutter.template_PREFIX}}_API_TOKEN` |
| :lock: `{{cookiecutter.template_PREFIX}}_PROD_API_TOKEN`      | API token for `production` env _(only define to override default)_ | `${{cookiecutter.template_PREFIX}}_API_TOKEN` |
| `prod-environment-url` / `{{cookiecutter.template_PREFIX}}_PROD_ENVIRONMENT_URL`| The production environment url _(only define for static environment URLs declaration and if different from default)_ | `${{cookiecutter.template_PREFIX}}_ENVIRONMENT_URL` |
| `prod-deploy-strategy` / `{{cookiecutter.template_PREFIX}}_PROD_DEPLOY_STRATEGY`| Defines the deployment to production strategy. One of `manual` (i.e. _one-click_) or `auto`. | `manual` |

+43 −19
Original line number Diff line number Diff line
@@ -130,7 +130,7 @@ spec:
      description: API url for `production` env _(only define to override default)_
      default: ''
    prod-deploy-strategy:
      description: Defines the deployment to production strategy.
      description: Defines the deployment to `production` strategy.
      options:
      - manual
      - auto
@@ -204,30 +204,54 @@ workflow:

variables:
  # variabilized tracking image
  TBC_TRACKING_IMAGE: "registry.gitlab.com/to-be-continuous/tools/tracking:master"
  TBC_TRACKING_IMAGE: registry.gitlab.com/to-be-continuous/tools/tracking:master

  # Default Docker image (use a public image - can be overridden)
  {{ cookiecutter.template_PREFIX }}_IMAGE: "registry.hub.docker.com/{{ cookiecutter.project_slug }}:latest"
  {{ cookiecutter.template_PREFIX }}_IMAGE: $[[ inputs.image ]]
{% if cookiecutter.template_type == 'build' %}
  # Default arguments for 'build' command
  {{ cookiecutter.template_PREFIX }}_BUILD_ARGS: "build --with-default-args"
  {{ cookiecutter.template_PREFIX }}_BUILD_ARGS: $[[ inputs.build-args ]]

  # Default arguments for 'publish' command
  {{ cookiecutter.template_PREFIX }}_PUBLISH_ARGS: "publish --with-default-args"
  {{ cookiecutter.template_PREFIX }}_PUBLISH_ENABLED: $[[ inputs.publish-enabled ]]
  {{ cookiecutter.template_PREFIX }}_PUBLISH_ARGS: $[[ inputs.publish-args ]]

  {{ cookiecutter.template_PREFIX }}_LINT_IMAGE: "registry.hub.docker.com/{{ cookiecutter.project_slug }}-lint:latest"
  {{ cookiecutter.template_PREFIX }}_LINT_ARGS: "--serevity=medium"
  {{ cookiecutter.template_PREFIX }}_LINT_DISABLED: $[[ inputs.lint-disabled ]]
  {{ cookiecutter.template_PREFIX }}_LINT_IMAGE: $[[ inputs.lint-image ]]
  {{ cookiecutter.template_PREFIX }}_LINT_ARGS: $[[ inputs.lint-args ]]

  {{ cookiecutter.template_PREFIX }}_DEPCHECK_IMAGE: "registry.hub.docker.com/{{ cookiecutter.project_slug }}-depcheck:latest"
  {{ cookiecutter.template_PREFIX }}_DEPCHECK_IMAGE: $[[ inputs.depcheck-image ]]
  {{ cookiecutter.template_PREFIX }}_DEPCHECK_ARGS: $[[ inputs.depcheck-args ]]
{%- elif cookiecutter.template_type == 'deploy' %}
  {{ cookiecutter.template_PREFIX }}_BASE_APP_NAME: "$CI_PROJECT_NAME"
  {{ cookiecutter.template_PREFIX }}_REVIEW_AUTOSTOP_DURATION: "4 hours"

  # default: one-click deploy
  {{ cookiecutter.template_PREFIX }}_PROD_DEPLOY_STRATEGY: manual
  {{ cookiecutter.template_PREFIX }}_BASE_APP_NAME: $[[ inputs.base-app-name ]]
  {{ cookiecutter.template_PREFIX }}_API_URL: $[[ inputs.api-url ]]
  {{ cookiecutter.template_PREFIX }}_ENVIRONMENT_URL: $[[ inputs.environment-url ]]
  {{ cookiecutter.template_PREFIX }}_SCRIPTS_DIR: $[[ inputs.scripts-dir ]]

  {{ cookiecutter.template_PREFIX }}_REVIEW_PROJECT: $[[ inputs.review-project ]]
  {{ cookiecutter.template_PREFIX }}_REVIEW_APP_NAME: $[[ inputs.review-app-name ]]
  {{ cookiecutter.template_PREFIX }}_REVIEW_ENVIRONMENT_URL: $[[ inputs.review-environment-url ]]
  {{ cookiecutter.template_PREFIX }}_REVIEW_API_URL: $[[ inputs.review-api-url ]]
  {{ cookiecutter.template_PREFIX }}_REVIEW_AUTOSTOP_DURATION: $[[ inputs.review-autostop-duration ]]

  {{ cookiecutter.template_PREFIX }}_INTEG_PROJECT: $[[ inputs.integ-project ]]
  {{ cookiecutter.template_PREFIX }}_INTEG_APP_NAME: $[[ inputs.integ-app-name ]]
  {{ cookiecutter.template_PREFIX }}_INTEG_ENVIRONMENT_URL: $[[ inputs.integ-environment-url ]]
  {{ cookiecutter.template_PREFIX }}_INTEG_API_URL: $[[ inputs.integ-api-url ]]

  {{ cookiecutter.template_PREFIX }}_STAGING_PROJECT: $[[ inputs.staging-project ]]
  {{ cookiecutter.template_PREFIX }}_STAGING_APP_NAME: $[[ inputs.staging-app-name ]]
  {{ cookiecutter.template_PREFIX }}_STAGING_ENVIRONMENT_URL: $[[ inputs.staging-environment-url ]]
  {{ cookiecutter.template_PREFIX }}_STAGING_API_URL: $[[ inputs.staging-api-url ]]

  {{ cookiecutter.template_PREFIX }}_PROD_PROJECT: $[[ inputs.prod-project ]]
  {{ cookiecutter.template_PREFIX }}_PROD_APP_NAME: $[[ inputs.prod-app-name ]]
  {{ cookiecutter.template_PREFIX }}_PROD_ENVIRONMENT_URL: $[[ inputs.prod-environment-url ]]
  {{ cookiecutter.template_PREFIX }}_PROD_API_URL: $[[ inputs.prod-api-url ]]
  {{ cookiecutter.template_PREFIX }}_PROD_DEPLOY_STRATEGY: $[[ inputs.prod-deploy-strategy ]]
{%- elif cookiecutter.template_type == 'acceptance' %}
  # Directory where {{ cookiecutter.template_PREFIX }} tests are implemented
  {{ cookiecutter.template_PREFIX }}_ROOT_DIR: "."
  {{ cookiecutter.template_PREFIX }}_PROJECT_DIR: $[[ inputs.project-dir ]]
  {{ cookiecutter.template_PREFIX }}_EXTRA_ARGS: $[[ inputs.extra-args ]]
  {{ cookiecutter.template_PREFIX }}_REVIEW_ENABLED: $[[ inputs.review-enabled ]]
{%- endif %}

  # default production ref name (pattern)
@@ -892,7 +916,7 @@ stages:
    - !reference [.{{ cookiecutter.template_prefix }}-scripts]
    - install_ca_certs "${CUSTOM_CA_CERTS:-$DEFAULT_CA_CERTS}"
    - eval_env_url
    - cd "${{ cookiecutter.template_PREFIX }}_ROOT_DIR"
    - cd "${{ cookiecutter.template_PREFIX }}_PROJECT_DIR"
    # TODO (if necessary): do setup stuff here
  script:
    # TODO: run {{ cookiecutter.cli_tool }} tests
@@ -903,11 +927,11 @@ stages:
    name: "$CI_JOB_NAME artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG"
    when: always
    paths:
      - ${{ cookiecutter.template_PREFIX }}_ROOT_DIR/reports/{{ cookiecutter.project_slug }}.*
      - ${{ cookiecutter.template_PREFIX }}_PROJECT_DIR/reports/{{ cookiecutter.project_slug }}.*
    reports:
      # TODO (if possible): Acceptance tests use JUnit format and GitLab integration (see: https://docs.gitlab.com/ee/ci/yaml/#artifactsreports)
      junit:
        - ${{ cookiecutter.template_PREFIX }}_ROOT_DIR/reports/{{ cookiecutter.project_slug }}.xunit.xml
        - ${{ cookiecutter.template_PREFIX }}_PROJECT_DIR/reports/{{ cookiecutter.project_slug }}.xunit.xml
    expire_in: 1 day
  rules:
    - !reference [.acceptance-policy, rules]