environment names (and other fields) are limited by an unknown set of restrictions
Problem to solve
As per https://gitlab.com/gitlab-com/support-forum/issues/2814, there are a myriad of scenarios that users have run into where environment names (and urls) result in a failed deployment/environment (or lack thereof).
Worse, due to #32599, they silently fail! (job still succeeds)
Ultimately I guess this issue is pending due to (and might be solved by): #17169 (moved)
In the meantime, we need to document this gotchas/limitations precisely. Why do SOME variables work, and others not? Does it have something to do with persisted variables? https://docs.gitlab.com/ee/ci/variables/where_variables_can_be_used.html#persisted-variables
Further details
Consider: https://gitlab.com/gitlab-com/support-forum/issues/2814#note_192205746
When I tested this, for example,
environment:
name: master/${CI_PIPELINE_ID}
export ENV_NAME="master/${CI_PIPELINE_ID}"
export ENV_NAME=master/23969
in a job that pushes said environment, it completely breaks and silently just says:
This job is creating a deployment to .
The theory in that CI_PIPELINE_ID
is empty, and master/
is an invalid environment name.
OK we can test this by doing:
environment:
name: master/pipeline-${CI_PIPELINE_ID}
export ENV_NAME="master/pipeline-${CI_PIPELINE_ID}"
export ENV_NAME=master/pipeline-23970
this time, we confirm our theory:
This job is creating a deployment to master/pipeline-.
Yikes. But if we use the project's CI_PIPELINE_IID
, things work!
environment:
name: master/${CI_PIPELINE_IID}
export ENV_NAME="master/${CI_PIPELINE_IID}"
export ENV_NAME=master/23978
and it works:
This job is creating a deployment to master/23978.
This is a very difficult bug to isolate for users, and the fact that it is silent really hurts.
Known Situation
Update these as we learn?
Functional
CI_COMMIT_REF_SLUG
CI_PIPELINE_IID
Broken / Empty
CI_PIPELINE_ID
CI_JOB_ID
Proposal
- At minimum, ASAP, we need to document whatever the current limitations are in https://docs.gitlab.com/ee/ci/yaml/#environment.
- Find/ref a ticket that commits to "fail job on environment fail" to stop failing silently.
- Explain why some variables work, and others do not. (persisted vars?)
Who can address the issue
TBD
Other links/references
#17169 (moved) gitlab-foss#42122 (moved) https://gitlab.com/gitlab-com/support-forum/issues/2814
https://docs.gitlab.com/ee/ci/variables/where_variables_can_be_used.html#persisted-variables https://docs.gitlab.com/ee/ci/environments/environments_dashboard.html https://docs.gitlab.com/ee/ci/environments.html#scoping-environments-with-specs https://docs.gitlab.com/ee/ci/yaml/#environment https://docs.gitlab.com/ee/ci/variables/predefined_variables.html