The above configuration will deploy 2 environments on each pipeline:
- on feature branches: `review/front/$CI_COMMIT_REF_NAME` and `review/back/$CI_COMMIT_REF_NAME`
- on the integration branch: `integration/front` and `integration/back`
- on the production branch: `staging/front` and `staging/back` (and finally `production/front` and `production/back`)
### Deployment output variables
Each deployment job produces _output variables_ that are propagated to downstream jobs (using [dotenv artifacts](https://docs.gitlab.com/ci/yaml/artifacts_reports/#artifactsreportsdotenv)):
@@ -214,6 +251,16 @@ Those variables may be freely used in downstream jobs (for instance to run accep
You may also add and propagate your own custom variables, by pushing them to the `gcloud.env` file in your [deployment script](#deployment-and-cleanup-scripts).
> [!important]
> If [multiple environments](#multiple-environments-support) are configured, the output variables are prefixed with a
> sluggified value of the `GCP_ENVIRONMENT_NAMESPACE` variable (stripped of punctuation characters and converted to lowercase):
>
> * `<namespace_slug>_environment_type`: set to the type of environment (`review`, `integration`, `staging` or `production`),
> * `<namespace_slug>_environment_name`: the application name (see below),
> * `<namespace_slug>_environment_url`: set to the environment URL (whether determined statically or dynamically).
>
> The output dotenv file will be `gcloud.env.<namespace_slug>` instead, and the dynamic variable `${environment_namespace}` can be used in your scripts and manifests to access the contextual value of `<namespace_slug>`.
## Configuration reference
### Secrets management
@@ -240,6 +287,7 @@ The Google Cloud template uses some global configuration used throughout all job
| `environment-namespace` / `GCP_ENVIRONMENT_NAMESPACE` | Extra [GitLab environments](https://docs.gitlab.com/ci/environments/) namespace _(only required when deploying [multiple environments](#multiple-environments-support))_<br/>:warning: must start with a slash `/` | _none_ |
| `scripts-dir` / `GCP_SCRIPTS_DIR` | Directory where Google Cloud scripts (deploy & cleanup) are located | `.` _(root project dir)_ |
"description":"The default environments url _(only define for static environment URLs declaration)_\n\n_supports late variable expansion (ex: `https://%{environment_name}.gcloud.acme.com`)_"
},
{
"name":"GCP_ENVIRONMENT_NAMESPACE",
"description":"Extra [GitLab environments](https://docs.gitlab.com/ci/environments/) namespace _(only required when deploying multiple environments)_\n\n:warning: must start with a slash `/`",
"advanced":true
},
{
"name":"GCP_SCRIPTS_DIR",
"description":"Directory where Google Cloud scripts (deploy & cleanup) are located",