Commit 35e614f6 authored by Nick Gaskill's avatar Nick Gaskill

Merge branch 'fix-environment-docs' into 'master'

Improve documentation about pipeline configuration for review apps

See merge request gitlab-org/gitlab!43953
parents d802e948 ca4d6ad8
...@@ -219,10 +219,17 @@ You can also specify a static part of the URL at `environment:url:`, such as ...@@ -219,10 +219,17 @@ You can also specify a static part of the URL at `environment:url:`, such as
The assigned URL for the `review/your-branch-name` environment is [visible in the UI](#using-the-environment-url). The assigned URL for the `review/your-branch-name` environment is [visible in the UI](#using-the-environment-url).
> **Notes:** Note the following:
>
> - `stop_review` doesn't generate a dotenv report artifact, so it won't recognize the `DYNAMIC_ENVIRONMENT_URL` variable. Therefore you should not set `environment:url:` in the `stop_review` job. - `stop_review` doesn't generate a dotenv report artifact, so it won't recognize the
> - If the environment URL is not valid (for example, the URL is malformed), the system doesn't update the environment URL. `DYNAMIC_ENVIRONMENT_URL` variable. Therefore you shouldn't set `environment:url:` in the
`stop_review` job.
- If the environment URL isn't valid (for example, the URL is malformed), the system doesn't update
the environment URL.
- If the script that runs in `stop_review` exists only in your repository and therefore can't use
`GIT_STRATEGY: none`, configure [pipelines for merge requests](../../ci/merge_request_pipelines/index.md)
for these jobs. This ensures that runners can fetch the repository even after a feature branch is
deleted. For more information, see [Ref Specs for Runners](../pipelines/index.md#ref-specs-for-runners).
### Configuring manual deployments ### Configuring manual deployments
...@@ -675,24 +682,23 @@ deploy_review: ...@@ -675,24 +682,23 @@ deploy_review:
name: review/$CI_COMMIT_REF_NAME name: review/$CI_COMMIT_REF_NAME
url: https://$CI_ENVIRONMENT_SLUG.example.com url: https://$CI_ENVIRONMENT_SLUG.example.com
on_stop: stop_review on_stop: stop_review
only: rules:
- branches - if: $CI_MERGE_REQUEST_ID
except:
- master
stop_review: stop_review:
stage: deploy stage: deploy
variables:
GIT_STRATEGY: none
script: script:
- echo "Remove review app" - echo "Remove review app"
when: manual
environment: environment:
name: review/$CI_COMMIT_REF_NAME name: review/$CI_COMMIT_REF_NAME
action: stop action: stop
rules:
- if: $CI_MERGE_REQUEST_ID
when: manual
``` ```
Setting the [`GIT_STRATEGY`](../yaml/README.md#git-strategy) to `none` is necessary in the If you can't use [Pipelines for merge requests](../merge_request_pipelines/index.md),
setting the [`GIT_STRATEGY`](../yaml/README.md#git-strategy) to `none` is necessary in the
`stop_review` job so that the [runner](https://docs.gitlab.com/runner/) won't `stop_review` job so that the [runner](https://docs.gitlab.com/runner/) won't
try to check out the code after the branch is deleted. try to check out the code after the branch is deleted.
...@@ -748,12 +754,16 @@ review_app: ...@@ -748,12 +754,16 @@ review_app:
name: review/$CI_COMMIT_REF_NAME name: review/$CI_COMMIT_REF_NAME
on_stop: stop_review_app on_stop: stop_review_app
auto_stop_in: 1 week auto_stop_in: 1 week
rules:
- if: $CI_MERGE_REQUEST_ID
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_NAME
action: stop action: stop
rules:
- if: $CI_MERGE_REQUEST_ID
when: manual when: manual
``` ```
......
...@@ -79,6 +79,27 @@ You can also configure specific aspects of your pipelines through the GitLab UI. ...@@ -79,6 +79,27 @@ You can also configure specific aspects of your pipelines through the GitLab UI.
- [Pipeline schedules](schedules.md). - [Pipeline schedules](schedules.md).
- [Custom CI/CD variables](../variables/README.md#custom-environment-variables). - [Custom CI/CD variables](../variables/README.md#custom-environment-variables).
### Ref Specs for Runners
When a runner picks a pipeline job, GitLab provides that job's metadata. This includes the [Git refspecs](https://git-scm.com/book/en/v2/Git-Internals-The-Refspec),
which indicate which ref (branch, tag, and so on) and commit (SHA1) are checked out from your
project repository.
This table lists the refspecs injected for each pipeline type:
| Pipeline type | Refspecs |
|--------------- |---------------------------------------- |
| Pipeline for Branches | `+refs/pipelines/<id>:refs/pipelines/<id>` and `+refs/heads/<name>:refs/remotes/origin/<name>` |
| pipeline for Tags | `+refs/pipelines/<id>:refs/pipelines/<id>` and `+refs/tags/<name>:refs/tags/<name>` |
| [Pipeline for Merge Requests](../merge_request_pipelines/index.md) | `+refs/pipelines/<id>:refs/pipelines/<id>` |
The refs `refs/heads/<name>` and `refs/tags/<name>` exist in your
project repository. GitLab generates the special ref `refs/pipelines/<id>` during a
running pipeline job. This ref can be created even after the associated branch or tag has been
deleted. It's therefore useful in some features such as [automatically stopping an environment](../environments/index.md#automatically-stopping-an-environment),
and [merge trains](../merge_request_pipelines/pipelines_for_merged_results/merge_trains/index.md)
that might run pipelines after branch deletion.
### View pipelines ### View pipelines
You can find the current and historical pipeline runs under your project's You can find the current and historical pipeline runs under your project's
......
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