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:
script:
- echo "Deploy a review app"
environment:
name: review/$CI_COMMIT_REF_NAME
name: review/$CI_COMMIT_REF_SLUG
url: https://$CI_ENVIRONMENT_SLUG.example.com
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
......@@ -109,9 +109,9 @@ deploy_review:
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.
- 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,
use `$CI_ENVIRONMENT_SLUG` instead. The `$CI_ENVIRONMENT_SLUG` variable is guaranteed to be unique.
......@@ -385,7 +385,7 @@ deploy_review:
script:
- echo "Deploy a review app"
environment:
name: review/$CI_COMMIT_REF_NAME
name: review/$CI_COMMIT_REF_SLUG
url: https://$CI_ENVIRONMENT_SLUG.example.com
on_stop: stop_review
rules:
......@@ -396,7 +396,7 @@ stop_review:
script:
- echo "Remove review app"
environment:
name: review/$CI_COMMIT_REF_NAME
name: review/$CI_COMMIT_REF_SLUG
action: stop
rules:
- if: $CI_MERGE_REQUEST_ID
......@@ -440,7 +440,7 @@ is created or updated. The environment runs until `stop_review_app` is executed:
review_app:
script: deploy-review-app
environment:
name: review/$CI_COMMIT_REF_NAME
name: review/$CI_COMMIT_REF_SLUG
on_stop: stop_review_app
auto_stop_in: 1 week
rules:
......@@ -449,7 +449,7 @@ review_app:
stop_review_app:
script: stop-review-app
environment:
name: review/$CI_COMMIT_REF_NAME
name: review/$CI_COMMIT_REF_SLUG
action: stop
rules:
- if: $CI_MERGE_REQUEST_ID
......@@ -538,7 +538,7 @@ then in the UI, the environments are grouped under that heading:
![Environment groups](img/environments_dynamic_groups_v13_10.png)
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
deploy_review:
......@@ -546,7 +546,7 @@ deploy_review:
script:
- echo "Deploy a review app"
environment:
name: review/$CI_COMMIT_REF_NAME
name: review/$CI_COMMIT_REF_SLUG
```
### Environment incident management
......@@ -776,14 +776,14 @@ To ensure the `action: stop` can always run when needed, you can:
deploy_review:
stage: deploy
environment:
name: review/$CI_COMMIT_REF_NAME
name: review/$CI_COMMIT_REF_SLUG
url: https://$CI_ENVIRONMENT_SLUG.example.com
on_stop: stop_review
stop_review:
stage: deploy
environment:
name: review/$CI_COMMIT_REF_NAME
name: review/$CI_COMMIT_REF_SLUG
action: stop
when: manual
```
......@@ -803,7 +803,7 @@ To ensure the `action: stop` can always run when needed, you can:
deploy_review:
stage: deploy
environment:
name: review/$CI_COMMIT_REF_NAME
name: review/$CI_COMMIT_REF_SLUG
url: https://$CI_ENVIRONMENT_SLUG.example.com
on_stop: stop_review
......@@ -812,7 +812,7 @@ To ensure the `action: stop` can always run when needed, you can:
needs:
- deploy_review
environment:
name: review/$CI_COMMIT_REF_NAME
name: review/$CI_COMMIT_REF_SLUG
action: stop
when: manual
```
......@@ -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. [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.
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.
......
......@@ -2136,7 +2136,7 @@ review_app:
stage: deploy
script: make deploy-app
environment:
name: review/$CI_COMMIT_REF_NAME
name: review/$CI_COMMIT_REF_SLUG
url: https://$CI_ENVIRONMENT_SLUG.example.com
on_stop: stop_review_app
......@@ -2147,7 +2147,7 @@ stop_review_app:
script: make delete-app
when: manual
environment:
name: review/$CI_COMMIT_REF_NAME
name: review/$CI_COMMIT_REF_SLUG
action: stop
```
......@@ -2197,7 +2197,7 @@ For example,
review_app:
script: deploy-review-app
environment:
name: review/$CI_COMMIT_REF_NAME
name: review/$CI_COMMIT_REF_SLUG
auto_stop_in: 1 day
```
......@@ -2267,12 +2267,12 @@ deploy as review app:
stage: deploy
script: make deploy
environment:
name: review/$CI_COMMIT_REF_NAME
name: review/$CI_COMMIT_REF_SLUG
url: https://$CI_ENVIRONMENT_SLUG.example.com/
```
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
`$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
......
......@@ -181,7 +181,7 @@ include:
review:
stage: deploy
environment:
name: review/$CI_COMMIT_REF_NAME
name: review/$CI_COMMIT_REF_SLUG
url: http://$CI_ENVIRONMENT_SLUG.example.com
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