Commit 556aaebc authored by Achilleas Pipinellis's avatar Achilleas Pipinellis

Finish "Stopping envs" and "Grouping similar envs" sections

[ci skip]
parent 54fc574e
......@@ -273,9 +273,9 @@ Last but not least, we tell the job to run [`only`][only] on branches
[`except`][only] master.
You are not bound to use only slashes in the dynamic environments' names (`/`),
but as we will see later, this will enable the "grouping similar environments"
You are not bound to use the same prefix or only slashes in the dynamic
environments' names (`/`), but as we will see later, this will enable the
[grouping similar environments](#grouping-similar-environments) feature.
The whole `.gitlab-ci.yml` looks like this so far:
......@@ -388,31 +388,74 @@ and finally manually deployed to the production server. What we just described
is a single workflow, but imagine tens of developers working on a project
at the same time. They each push to their branches, and dynamic environments are
created all the time. In that case, we probably need to do some clean up. Read
next how environments can be closed.
next how environments can be stopped.
## Closing an environment
## Stopping an environment
By stopping an environment, you are effectively terminating its recording of the
deployments that happen in it.
Starting with GitLab 8.14, dynamic environments will be stopped automatically
when their associated branch is removed.
There is a special case where environments can be manually closed. That can
happen if you provide another job for that matter. The syntax is a little
tricky since a job calls another job to do the job.
Consider the following example where the `deploy_review` calls the `stop_review`
to clean up and stop the environment:
stage: deploy
- rsync -av --delete public /srv/nginx/pages/$CI_BUILD_REF_NAME
- echo "Deploy a review app"
name: review/$CI_BUILD_REF_NAME
url: https://$
on_stop: stop_review
- branches
- master
script: rm -rf /srv/nginx/pages/$CI_BUILD_REF_NAME
- echo "Remove review app"
when: manual
name: review/$CI_BUILD_REF_NAME
action: stop
You can read more in the [`.gitlab-ci.yml` reference][onstop].
## Grouping similar environments
folders in environments page
> [Introduced][ce-7015] in GitLab 8.14.
As we've seen in the [dynamic environments](#dynamic-environments), you can
In short, environments that are named like `type/foo` are presented under a
group named `type`.
In our minimal example, we name the environments `review/$CI_BUILD_REF_NAME`
where `$CI_BUILD_REF_NAME` is the branch name:
stage: deploy
- echo "Deploy a review app"
name: review/$CI_BUILD_REF_NAME
In that case, if you visit the Environments page, and provided the branches
exist, you should see something like:
![Environment groups](img/environments_dynamic_groups.png)
## Checkout deployments locally
......@@ -435,22 +478,6 @@ Below are some links you may find interesting:
- [A blog post on Deployments & Environments](
- [Review Apps]( Expand dynamic environments to deploy your code for every branch
- View environments +
- View deployments +
- Rollback deployments +
- Run deployments +
- View link to environment URL
- View last commit message of deployment +
- View person who performed the deployment +
- View commit SHA that triggered the deployment +
- View branch the deployment was based on +
- View time ago the deployment was performed +
[jobs]: yaml/
[yaml]: yaml/
......@@ -460,3 +487,5 @@ Actions
[variables]: variables/
[env-name]: yaml/
[only]: yaml/
[onstop]: yaml/
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