Allow users to specify environment tier via .gitlab-ci.yml
What does this MR do?
In !55471 (merged), we've added the tier
column to the
environments
table. This column is to specify the Deployment environment, which is one of production
, staging
, testing
, development
,
or other
.
In this MR, we allow users to specify the tier via .gitlab-ci.yml. We add a new key named environment:deployment_tier:
in the .gitlab-ci.yml syntax:
For example, you can specify that customer-portal
environment is production
tier.
deploy-to-production:
script: echo 'Deploy to production'
environment:
name: customer-portal
deployment_tier: production
In general, the tier is automatically set based on the environment:name:
, but sometimes user puts an application codename (e.g. customer-portal
) to an environment and an unexpected tier could be set. environment:deployment_tier
is a complement in such case.
Related #300741 (closed)
Screenshots (strongly suggested)
Specify the environment tier in .gitlab-ci.yml
Deployment job passed
The tier is correctly reflected on the row
[2] pry(main)> project.environments.find_by_name('customer-portal').tier
Environment Load (0.4ms) SELECT "environments".* FROM "environments" WHERE "environments"."project_id" = $1 AND "environments"."name" = $2 LIMIT $3 /*application:console,line:/devkitkat/services/rails/cache/ruby/2.7.0/gems/activerecord-6.0.3.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `exec_query'*/ [["project_id", 35], ["name", "customer-portal"], ["LIMIT", 1]]
=> "production"
Specify the unknown tier in .gitlab-ci.yml
Show a proper error
Does this MR meet the acceptance criteria?
Conformity
-
📋 Does this MR need a changelog?-
I have included a changelog entry. -
I have not included a changelog entry because this feature is behind a feature flag disabled by default.
-
- [-] Documentation (if required) => Documentation will be added at feature flag removal.
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team