CI_ENVIRONMENT_NAME and CI_ENVIRONMENT_SLUG aren't set when branch name contains #

Summary

CI_ENVIRONMENT_NAME and CI_ENVIRONMENT_SLUG are not set when branch name contains #

Steps to reproduce

  1. Create a branch with a # in the name (as in test#123)
  2. Run env from a GitLab CI job
  3. Verify that the variables above are not set

Example Project

https://gitlab.com/tpresa/branch-names-test

What is the current bug behavior?

Env vars CI_ENVIRONMENT_NAME and CI_ENVIRONMENT_SLUG are not set

What is the expected correct behavior?

Env vars CI_ENVIRONMENT_NAME and CI_ENVIRONMENT_SLUG should be set

Output of checks

This bug happens on GitLab.com

ZD https://gitlab.zendesk.com/agent/tickets/109934 (internal)