Then at service binding, the application gets the three credential parameters as specified in the descriptor file, that are `user`, `password` and `url`.
### Multiple environments support
The Cloud Foundry template allows deploying multiple environments in parallel. Use cases of this include:
- monorepo, where a single Git repository might host several separate deployable components or apps,
- multi-instances deployment of the same application.
This feature can be enabled using the [parallel matrix jobs](https://docs.gitlab.com/ee/ci/yaml/#parallelmatrix)
pattern at the `.cf-env-base` job level (this is the top parent job of all deployment jobs).
Environments namespacing is ensured by the `CF_ENVIRONMENT_NAMESPACE` variable (must start with a slash `/`).
Here is the example of the `.gitlab-ci.yml` file for a project deploying both a frontend and a backend applications:
```yaml
.cf-env-base:
parallel:
matrix:
- CF_ENVIRONMENT_NAMESPACE: "/front"
# Cloud Foundry scripts are located in the ./front/ directory
CF_SCRIPTS_DIR: "front"
- CF_ENVIRONMENT_NAMESPACE: "/back"
# Cloud Foundry scripts are located in the ./back/ directory
CF_SCRIPTS_DIR: "back"
# ⚠ on_stop must be unset when defining parallel:matrix environments
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)):
@@ -342,6 +379,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 `cloudfoundry.env` file in your [deployment scripts](#hook-scripts).
> [!important]
> If [multiple environments](#multiple-environments-support) are configured, the output variables are prefixed with a
> sluggified value of the `CF_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 `cloudfoundry.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
@@ -365,6 +412,7 @@ The Cloud Foundry template uses some global configuration used throughout all jo
| Input / Variable | Description | Default Value |
| `cli-image` / `CF_CLI_IMAGE` | The Docker image used to run CF CLI commands <br/>:warning: **set the version required by your Cloud Foundry server** | `docker.io/governmentpaas/cf-cli` <br/>[](https://to-be-continuous.gitlab.io/doc/secu/trivy-CF_CLI_IMAGE) |
| `environment-namespace` / `CF_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_ |
"description":"The Docker image used to run CF CLI commands - **set the version required by your Cloud Foundry server**",
"default":"docker.io/governmentpaas/cf-cli"
},
{
"name":"CF_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":"CF_MANIFEST_BASENAME",
"description":"CF manifest file basename (without extension nor env suffix)",