Fix construct release environments vars script
What does this MR do and why?
Fix construct release environments vars script
Use CI_COMMIT_REF_NAME instead of CI_COMMIT_REF_SLUG, because the the later one does some string conversions per our document (https://docs.gitlab.com/ee/ci/variables/predefined_variables.html). This breaks the current regex, make it hard to understand and lead to possible confusion in the future.
Ref: gitlab-com/gl-infra/delivery#20371 (closed)
Detailed explanation
From our docs about CI_COMMIT_REF_SLUG
:
https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
CI_COMMIT_REF_NAME
in lowercase, shortened to 63 bytes, and with everything except0-9
anda-z
replaced with-
. No leading / trailing-
. Use in URLs, host names and domain names.
So, an example:
- If the tag is v17.2.0-rc42-ee
-
CI_COMMIT_REF_NAME
is the same - v17.2.0-rc42-ee -
CI_COMMIT_REF_SLUG
converts all.
to be-
, so its value is v17-2-0-rc42-ee. Because of that, it does not the regex of the script anymore, so it producesENVIRONMENT=v17-2-0-rc42-security
, which is unexpected.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Testing
In a test repository, I tested on all 3 cases of CI_COMMIT_REF_NAME
:
Stable branch
https://gitlab.com/dat.tang.gitlab/test-gitlab-ci/-/pipelines/1377363729
RC version tag
https://gitlab.com/dat.tang.gitlab/test-gitlab-ci/-/pipelines/1377364815
Release version tag
https://gitlab.com/dat.tang.gitlab/test-gitlab-ci/-/pipelines/1377365759