Commit c742011d authored by feistel's avatar feistel Committed by Marcel Amirault

docs: document to use CI_COMMIT_REF_SLUG instead of CI_COMMIT_REF_NAME for review apps

parent 24875d7d
...@@ -99,7 +99,7 @@ deploy_review: ...@@ -99,7 +99,7 @@ deploy_review:
script: script:
- echo "Deploy a review app" - echo "Deploy a review app"
environment: environment:
name: review/$CI_COMMIT_REF_NAME name: review/$CI_COMMIT_REF_SLUG
url: https://$CI_ENVIRONMENT_SLUG.example.com url: https://$CI_ENVIRONMENT_SLUG.example.com
rules: rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
...@@ -109,9 +109,9 @@ deploy_review: ...@@ -109,9 +109,9 @@ deploy_review:
In this example: In this example:
- The `name` is `review/$CI_COMMIT_REF_NAME`. Because the [environment name](../yaml/index.md#environmentname) - The `name` is `review/$CI_COMMIT_REF_SLUG`. Because the [environment name](../yaml/index.md#environmentname)
can contain slashes (`/`), you can use this pattern to distinguish between dynamic and static environments. can contain slashes (`/`), you can use this pattern to distinguish between dynamic and static environments.
- For the `url`, you could use `$CI_COMMIT_REF_NAME`, but because this value - For the `url`, you could use `$CI_COMMIT_REF_SLUG`, but because this value
may contain a `/` or other characters that would not be valid in a domain name or URL, may contain a `/` or other characters that would not be valid in a domain name or URL,
use `$CI_ENVIRONMENT_SLUG` instead. The `$CI_ENVIRONMENT_SLUG` variable is guaranteed to be unique. use `$CI_ENVIRONMENT_SLUG` instead. The `$CI_ENVIRONMENT_SLUG` variable is guaranteed to be unique.
...@@ -385,7 +385,7 @@ deploy_review: ...@@ -385,7 +385,7 @@ deploy_review:
script: script:
- echo "Deploy a review app" - echo "Deploy a review app"
environment: environment:
name: review/$CI_COMMIT_REF_NAME name: review/$CI_COMMIT_REF_SLUG
url: https://$CI_ENVIRONMENT_SLUG.example.com url: https://$CI_ENVIRONMENT_SLUG.example.com
on_stop: stop_review on_stop: stop_review
rules: rules:
...@@ -396,7 +396,7 @@ stop_review: ...@@ -396,7 +396,7 @@ stop_review:
script: script:
- echo "Remove review app" - echo "Remove review app"
environment: environment:
name: review/$CI_COMMIT_REF_NAME name: review/$CI_COMMIT_REF_SLUG
action: stop action: stop
rules: rules:
- if: $CI_MERGE_REQUEST_ID - if: $CI_MERGE_REQUEST_ID
...@@ -440,7 +440,7 @@ is created or updated. The environment runs until `stop_review_app` is executed: ...@@ -440,7 +440,7 @@ is created or updated. The environment runs until `stop_review_app` is executed:
review_app: review_app:
script: deploy-review-app script: deploy-review-app
environment: environment:
name: review/$CI_COMMIT_REF_NAME name: review/$CI_COMMIT_REF_SLUG
on_stop: stop_review_app on_stop: stop_review_app
auto_stop_in: 1 week auto_stop_in: 1 week
rules: rules:
...@@ -449,7 +449,7 @@ review_app: ...@@ -449,7 +449,7 @@ review_app:
stop_review_app: stop_review_app:
script: stop-review-app script: stop-review-app
environment: environment:
name: review/$CI_COMMIT_REF_NAME name: review/$CI_COMMIT_REF_SLUG
action: stop action: stop
rules: rules:
- if: $CI_MERGE_REQUEST_ID - if: $CI_MERGE_REQUEST_ID
...@@ -538,7 +538,7 @@ then in the UI, the environments are grouped under that heading: ...@@ -538,7 +538,7 @@ then in the UI, the environments are grouped under that heading:
![Environment groups](img/environments_dynamic_groups_v13_10.png) ![Environment groups](img/environments_dynamic_groups_v13_10.png)
The following example shows how to start your environment names with `review`. The following example shows how to start your environment names with `review`.
The `$CI_COMMIT_REF_NAME` variable is populated with the branch name at runtime: The `$CI_COMMIT_REF_SLUG` variable is populated with the branch name at runtime:
```yaml ```yaml
deploy_review: deploy_review:
...@@ -546,7 +546,7 @@ deploy_review: ...@@ -546,7 +546,7 @@ deploy_review:
script: script:
- echo "Deploy a review app" - echo "Deploy a review app"
environment: environment:
name: review/$CI_COMMIT_REF_NAME name: review/$CI_COMMIT_REF_SLUG
``` ```
### Environment incident management ### Environment incident management
...@@ -776,14 +776,14 @@ To ensure the `action: stop` can always run when needed, you can: ...@@ -776,14 +776,14 @@ To ensure the `action: stop` can always run when needed, you can:
deploy_review: deploy_review:
stage: deploy stage: deploy
environment: environment:
name: review/$CI_COMMIT_REF_NAME name: review/$CI_COMMIT_REF_SLUG
url: https://$CI_ENVIRONMENT_SLUG.example.com url: https://$CI_ENVIRONMENT_SLUG.example.com
on_stop: stop_review on_stop: stop_review
stop_review: stop_review:
stage: deploy stage: deploy
environment: environment:
name: review/$CI_COMMIT_REF_NAME name: review/$CI_COMMIT_REF_SLUG
action: stop action: stop
when: manual when: manual
``` ```
...@@ -803,7 +803,7 @@ To ensure the `action: stop` can always run when needed, you can: ...@@ -803,7 +803,7 @@ To ensure the `action: stop` can always run when needed, you can:
deploy_review: deploy_review:
stage: deploy stage: deploy
environment: environment:
name: review/$CI_COMMIT_REF_NAME name: review/$CI_COMMIT_REF_SLUG
url: https://$CI_ENVIRONMENT_SLUG.example.com url: https://$CI_ENVIRONMENT_SLUG.example.com
on_stop: stop_review on_stop: stop_review
...@@ -812,7 +812,7 @@ To ensure the `action: stop` can always run when needed, you can: ...@@ -812,7 +812,7 @@ To ensure the `action: stop` can always run when needed, you can:
needs: needs:
- deploy_review - deploy_review
environment: environment:
name: review/$CI_COMMIT_REF_NAME name: review/$CI_COMMIT_REF_SLUG
action: stop action: stop
when: manual when: manual
``` ```
...@@ -57,7 +57,7 @@ The process of configuring Review Apps is as follows: ...@@ -57,7 +57,7 @@ The process of configuring Review Apps is as follows:
1. Set up the infrastructure to host and deploy the Review Apps (check the [examples](#review-apps-examples) below). 1. Set up the infrastructure to host and deploy the Review Apps (check the [examples](#review-apps-examples) below).
1. [Install](https://docs.gitlab.com/runner/install/) and [configure](https://docs.gitlab.com/runner/commands/) a runner to do deployment. 1. [Install](https://docs.gitlab.com/runner/install/) and [configure](https://docs.gitlab.com/runner/commands/) a runner to do deployment.
1. Set up a job in `.gitlab-ci.yml` that uses the [predefined CI/CD variable](../variables/index.md) `${CI_COMMIT_REF_NAME}` 1. Set up a job in `.gitlab-ci.yml` that uses the [predefined CI/CD variable](../variables/index.md) `${CI_COMMIT_REF_SLUG}`
to create dynamic environments and restrict it to run only on branches. to create dynamic environments and restrict it to run only on branches.
Alternatively, you can get a YML template for this job by [enabling review apps](#enable-review-apps-button) for your project. Alternatively, you can get a YML template for this job by [enabling review apps](#enable-review-apps-button) for your project.
1. Optionally, set a job that [manually stops](../environments/index.md#stop-an-environment) the Review Apps. 1. Optionally, set a job that [manually stops](../environments/index.md#stop-an-environment) the Review Apps.
......
...@@ -2136,7 +2136,7 @@ review_app: ...@@ -2136,7 +2136,7 @@ review_app:
stage: deploy stage: deploy
script: make deploy-app script: make deploy-app
environment: environment:
name: review/$CI_COMMIT_REF_NAME name: review/$CI_COMMIT_REF_SLUG
url: https://$CI_ENVIRONMENT_SLUG.example.com url: https://$CI_ENVIRONMENT_SLUG.example.com
on_stop: stop_review_app on_stop: stop_review_app
...@@ -2147,7 +2147,7 @@ stop_review_app: ...@@ -2147,7 +2147,7 @@ stop_review_app:
script: make delete-app script: make delete-app
when: manual when: manual
environment: environment:
name: review/$CI_COMMIT_REF_NAME name: review/$CI_COMMIT_REF_SLUG
action: stop action: stop
``` ```
...@@ -2197,7 +2197,7 @@ For example, ...@@ -2197,7 +2197,7 @@ For example,
review_app: review_app:
script: deploy-review-app script: deploy-review-app
environment: environment:
name: review/$CI_COMMIT_REF_NAME name: review/$CI_COMMIT_REF_SLUG
auto_stop_in: 1 day auto_stop_in: 1 day
``` ```
...@@ -2267,12 +2267,12 @@ deploy as review app: ...@@ -2267,12 +2267,12 @@ deploy as review app:
stage: deploy stage: deploy
script: make deploy script: make deploy
environment: environment:
name: review/$CI_COMMIT_REF_NAME name: review/$CI_COMMIT_REF_SLUG
url: https://$CI_ENVIRONMENT_SLUG.example.com/ url: https://$CI_ENVIRONMENT_SLUG.example.com/
``` ```
The `deploy as review app` job is marked as a deployment to dynamically The `deploy as review app` job is marked as a deployment to dynamically
create the `review/$CI_COMMIT_REF_NAME` environment. `$CI_COMMIT_REF_NAME` create the `review/$CI_COMMIT_REF_SLUG` environment. `$CI_COMMIT_REF_SLUG`
is a [CI/CD variable](../variables/index.md) set by the runner. The is a [CI/CD variable](../variables/index.md) set by the runner. The
`$CI_ENVIRONMENT_SLUG` variable is based on the environment name, but suitable `$CI_ENVIRONMENT_SLUG` variable is based on the environment name, but suitable
for inclusion in URLs. If the `deploy as review app` job runs in a branch named for inclusion in URLs. If the `deploy as review app` job runs in a branch named
......
...@@ -181,7 +181,7 @@ include: ...@@ -181,7 +181,7 @@ include:
review: review:
stage: deploy stage: deploy
environment: environment:
name: review/$CI_COMMIT_REF_NAME name: review/$CI_COMMIT_REF_SLUG
url: http://$CI_ENVIRONMENT_SLUG.example.com url: http://$CI_ENVIRONMENT_SLUG.example.com
script: script:
- run_deploy_script - run_deploy_script
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment