Deployment tier guesses incorrect tier for string 'nonprod'
Summary
Deployment tiers are determined based on a regex of the deployment name. The strings prod
or production
will be linked to the production
deployment tier. The regex incorrectly wraps nonprod
as a production tier.
Steps to reproduce
A job created with the following parameters in the .gitlab-ci.yml
will mark nonprod
as a production tier:
deploy_nonprod:
stage: staging
script:
- echo "Deploy to non-production server"
environment:
name: nonprod
url: https://example.com
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: manual
What is the current bug behavior?
The string nonprod
is marked as a production tier.
What is the expected correct behavior?
The string nonprod
should be marked as staging or testing.
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true
)(we will only investigate if the tests are passing)
Possible fixes
Change the following regex to exclude nonprod:
https://gitlab.com/gitlab-org/gitlab/-/blob/v15.4.2-ee/app/models/environment.rb#L545