Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'doc/ci/environments')
-rw-r--r--doc/ci/environments/img/protected_access_group_v13_6.pngbin0 -> 17599 bytes
-rw-r--r--doc/ci/environments/index.md48
-rw-r--r--doc/ci/environments/protected_environments.md59
3 files changed, 84 insertions, 23 deletions
diff --git a/doc/ci/environments/img/protected_access_group_v13_6.png b/doc/ci/environments/img/protected_access_group_v13_6.png
new file mode 100644
index 00000000000..9c39e4362e8
--- /dev/null
+++ b/doc/ci/environments/img/protected_access_group_v13_6.png
Binary files differ
diff --git a/doc/ci/environments/index.md b/doc/ci/environments/index.md
index baf2156e64a..361b7217d17 100644
--- a/doc/ci/environments/index.md
+++ b/doc/ci/environments/index.md
@@ -34,8 +34,7 @@ currently being deployed or has been deployed on your servers.
It's important to know that:
- Environments are like tags for your CI jobs, describing where code gets deployed.
-- Deployments are created when [jobs](../yaml/README.md#introduction) deploy versions of code to environments,
- so every environment can have one or more deployments.
+- Deployments are created when [GitLab CI/CD](../yaml/README.md) is used to deploy versions of code to environments.
GitLab:
@@ -219,10 +218,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).
-> **Notes:**
->
-> - `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.
-> - If the environment URL is not valid (for example, the URL is malformed), the system doesn't update the environment URL.
+Note the following:
+
+- `stop_review` doesn't generate a dotenv report artifact, so it won't recognize the
+ `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
@@ -304,7 +310,7 @@ Dynamic environments are a fundamental part of [Review apps](../review_apps/inde
#### Allowed variables
-The `name` and `url` parameters for dynamic environments can use most available CI/CD variables,
+The `name` and `url` keywords for dynamic environments can use most available CI/CD variables,
including:
- [Predefined environment variables](../variables/README.md#predefined-environment-variables)
@@ -436,7 +442,7 @@ The configuration in this section provides a full development workflow where you
- Tested.
- Built.
- Deployed as a Review App.
-- Deployed to a staging server once the merge request is merged.
+- Deployed to a staging server after the merge request is merged.
- Finally, able to be manually deployed to the production server.
The following combines the previous configuration examples, including:
@@ -675,24 +681,23 @@ deploy_review:
name: review/$CI_COMMIT_REF_NAME
url: https://$CI_ENVIRONMENT_SLUG.example.com
on_stop: stop_review
- only:
- - branches
- except:
- - master
+ rules:
+ - if: $CI_MERGE_REQUEST_ID
stop_review:
stage: deploy
- variables:
- GIT_STRATEGY: none
script:
- echo "Remove review app"
- when: manual
environment:
name: review/$CI_COMMIT_REF_NAME
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`](../runners/README.md#git-strategy) to `none` is necessary in the
`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.
@@ -748,13 +753,17 @@ review_app:
name: review/$CI_COMMIT_REF_NAME
on_stop: stop_review_app
auto_stop_in: 1 week
+ rules:
+ - if: $CI_MERGE_REQUEST_ID
stop_review_app:
script: stop-review-app
environment:
name: review/$CI_COMMIT_REF_NAME
action: stop
- when: manual
+ rules:
+ - if: $CI_MERGE_REQUEST_ID
+ when: manual
```
As long as a merge request is active and keeps getting new commits,
@@ -923,11 +932,10 @@ the [Kubernetes integration](../../user/project/clusters/index.md)), GitLab can
a terminal session to your environment.
This is a powerful feature that allows you to debug issues without leaving the comfort
-of your web browser. To enable it, just follow the instructions given in the service integration
+of your web browser. To enable it, follow the instructions given in the service integration
documentation.
-NOTE: **Note:**
-Container-based deployments often lack basic tools (like an editor), and may
+Note that container-based deployments often lack basic tools (like an editor), and may
be stopped or restarted at any time. If this happens, you will lose all your
changes. Treat this as a debugging tool, not a comprehensive online IDE.
diff --git a/doc/ci/environments/protected_environments.md b/doc/ci/environments/protected_environments.md
index 87bced29906..eeb95947ba1 100644
--- a/doc/ci/environments/protected_environments.md
+++ b/doc/ci/environments/protected_environments.md
@@ -45,6 +45,61 @@ To protect an environment:
The protected environment will now appear in the list of protected environments.
+### Use the API to protect an environment
+
+Alternatively, you can use the API to protect an environment:
+
+1. Use a project with a CI that creates an environment. For example:
+
+ ```yaml
+ stages:
+ - test
+ - deploy
+
+ test:
+ stage: test
+ script:
+ - 'echo "Testing Application: ${CI_PROJECT_NAME}"'
+
+ production:
+ stage: deploy
+ when: manual
+ script:
+ - 'echo "Deploying to ${CI_ENVIRONMENT_NAME}"'
+ environment:
+ name: ${CI_JOB_NAME}
+ ```
+
+1. Use the UI to [create a new group](../../user/group/index.md#create-a-new-group).
+ For example, this group is called `protected-access-group` and has the group ID `9899826`. Note
+ that the rest of the examples in these steps use this group.
+
+ ![Group Access](img/protected_access_group_v13_6.png)
+
+1. Use the API to add a user to the group as a reporter:
+
+ ```shell
+ $ curl --request POST --header "PRIVATE-TOKEN: xxxxxxxxxxxx" --data "user_id=3222377&access_level=20" "https://gitlab.com/api/v4/groups/9899826/members"
+
+ {"id":3222377,"name":"Sean Carroll","username":"sfcarroll","state":"active","avatar_url":"https://assets.gitlab-static.net/uploads/-/system/user/avatar/3222377/avatar.png","web_url":"https://gitlab.com/sfcarroll","access_level":20,"created_at":"2020-10-26T17:37:50.309Z","expires_at":null}
+ ```
+
+1. Use the API to add the group to the project as a reporter:
+
+ ```shell
+ $ curl --request POST --header "PRIVATE-TOKEN: xxxxxxxxxxxx" --request POST "https://gitlab.com/api/v4/projects/22034114/share?group_id=9899826&group_access=20"
+
+ {"id":1233335,"project_id":22034114,"group_id":9899826,"group_access":20,"expires_at":null}
+ ```
+
+1. Use the API to add the group with protected environment access:
+
+ ```shell
+ curl --header 'Content-Type: application/json' --request POST --data '{"name": "production", "deploy_access_levels": [{"group_id": 9899826}]}' --header "PRIVATE-TOKEN: xxxxxxxxxxx" "https://gitlab.com/api/v4/projects/22034114/protected_environments"
+ ```
+
+The group now has access and can be seen in the UI.
+
## Environment access by group membership
A user may be granted access to protected environments as part of
@@ -72,8 +127,7 @@ they have the following privileges:
Users granted access to a protected environment, but not push or merge access
to the branch deployed to it, are only granted access to deploy the environment.
-NOTE: **Note:**
-Deployment-only access is the only possible access level for users with
+Note that deployment-only access is the only possible access level for users with
[Reporter permissions](../../user/permissions.md).
## Modifying and unprotecting environments
@@ -84,7 +138,6 @@ Maintainers can:
**Allowed to Deploy** dropdown menu.
- Unprotect a protected environment by clicking the **Unprotect** button for that environment.
-NOTE: **Note:**
After an environment is unprotected, all access entries are deleted and must
be re-entered if the environment is re-protected.