Commit 8009db27 authored by Michael Kozono's avatar Michael Kozono

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

Add documentation for environment tier [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!56081
parents a944977d 796141f5
......@@ -461,8 +461,6 @@ class Environment < ApplicationRecord
end
def ensure_environment_tier
return unless ::Feature.enabled?(:environment_tier, project, default_enabled: :yaml)
self.tier ||= guess_tier
end
......
......@@ -68,7 +68,7 @@ module Deployments
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
......
---
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
......@@ -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.
......
......@@ -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.
......
......@@ -15,7 +15,7 @@ module Gitlab
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
......
......@@ -123,16 +123,6 @@ RSpec.describe Gitlab::Ci::Pipeline::Seed::Environment do
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
......
......@@ -53,18 +53,6 @@ RSpec.describe Environment, :use_clean_rails_memory_store_caching do
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
......
......@@ -168,16 +168,6 @@ RSpec.describe Deployments::UpdateEnvironmentService do
.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
......
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