Skip to content
Snippets Groups Projects
Commit 796141f5 authored by Shinya Maeda's avatar Shinya Maeda Committed by Michael Kozono
Browse files

Add documentation for environment tier

This commit adds the documentation for environment tier
feature that was added in GitLab 13.10.
parent 7a55aa8d
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -461,8 +461,6 @@ def generate_slug
end
 
def ensure_environment_tier
return unless ::Feature.enabled?(:environment_tier, project, default_enabled: :yaml)
self.tier ||= guess_tier
end
 
Loading
Loading
Loading
Loading
@@ -68,7 +68,7 @@ def renew_auto_stop_in
end
 
def renew_deployment_tier
return unless deployable && ::Feature.enabled?(:environment_tier, deployable.project, default_enabled: :yaml)
return unless deployable
 
if (tier = deployable.environment_deployment_tier)
environment.tier = tier
Loading
Loading
---
title: Support environment deployment tier
merge_request: 56081
author:
type: added
---
name: environment_tier
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/55471
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/323166
milestone: '13.10'
type: development
group: group::release
default_enabled: false
Loading
Loading
@@ -123,6 +123,30 @@ Some variables cannot be used as environment names or URLs.
For more information about the `environment` keywords, see
[the `.gitlab-ci.yml` keyword reference](../yaml/README.md#environment).
 
## Deployment tier of environments (**FREE**)
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/300741) in GitLab 13.10.
There are cases where you might want to use a code name as an environment name instead of using
an [industry standard](https://en.wikipedia.org/wiki/Deployment_environment). For example, your environment might be called `customer-portal` instead of `production`.
This is perfectly fine, however, it loses information that the specific
environment is used as production.
To keep information that a specific environment is for production or
some other use, you can set one of the following tiers to each environment:
| Environment tier | Environment names examples |
| ---- | -------- |
| `production` | Production, Live |
| `staging` | Staging, Model, Pre, Demo |
| `testing` | Test, QC |
| `development` | Dev, [Review apps](../review_apps/index.md), Trunk |
| `other` | |
By default, an approximate tier is automatically guessed and set from [the environment name](../yaml/README.md#environmentname).
Alternatively, you can specify a specific tier with `deployment_tier` keyword,
see the [`.gitlab-ci.yml` syntax reference](../yaml/README.md#environmentdeployment_tier) for more details.
## Configure manual deployments
 
You can create a job that requires someone to manually start the deployment.
Loading
Loading
Loading
Loading
@@ -2632,6 +2632,23 @@ that are [managed by GitLab](../../user/project/clusters/index.md#gitlab-managed
To follow progress on support for GitLab-managed clusters, see the
[relevant issue](https://gitlab.com/gitlab-org/gitlab/-/issues/38054).
 
#### `environment:deployment_tier`
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/27630) in GitLab 13.10.
Use the `deployment_tier` keyword to specify the tier of the deployment environment:
```yaml
deploy:
script: echo
environment:
name: customer-portal
deployment_tier: production
```
For more information,
see [Deployment tier of environments](../environments/index.md#deployment-tier-of-environments).
#### Dynamic environments
 
Use CI/CD [variables](../variables/README.md) to dynamically name environments.
Loading
Loading
Loading
Loading
@@ -15,7 +15,7 @@ def to_resource
environments.safe_find_or_create_by(name: expanded_environment_name) do |environment|
# Initialize the attributes at creation
environment.auto_stop_in = auto_stop_in
environment.tier = deployment_tier if ::Feature.enabled?(:environment_tier, job.project, default_enabled: :yaml)
environment.tier = deployment_tier
end
end
 
Loading
Loading
Loading
Loading
@@ -123,16 +123,6 @@
expect { subject }.to raise_error(ArgumentError, "'unknown' is not a valid tier")
end
end
context 'when environment_tier feature flag is disabled' do
before do
stub_feature_flags(environment_tier: false)
end
it 'does not set the specified tier' do
expect(subject.tier).to be_nil
end
end
end
 
context 'when environment has already been created' do
Loading
Loading
Loading
Loading
@@ -53,18 +53,6 @@
 
expect { environment.update!(name: 'gstg') }.not_to change { environment.reload.tier }
end
context 'when environment_tier feature flag is disabled' do
before do
stub_feature_flags(environment_tier: false)
end
it 'does not ensure environment tier' do
environment = build(:environment, name: 'gprd', tier: nil)
expect { environment.save }.not_to change { environment.tier }
end
end
end
 
describe '.order_by_last_deployed_at' do
Loading
Loading
Loading
Loading
@@ -168,16 +168,6 @@
.to change { environment.reset.tier }.from(nil).to('other')
end
end
context 'when environment_tier feature flag is disabled' do
before do
stub_feature_flags(environment_tier: false)
end
it 'does not set the specified deployment tier' do
expect { subject.execute }.not_to change { environment.reset.tier }
end
end
end
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment