Invalid environment name generated using $CI_COMMIT_REF_NAME silently fails to create environment

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

  • Close this issue

Summary

Environment names can only contain certain characters, and an error is generated in the UI if an invalid character is used. However, via .gitlab-ci.yml, the job succeeds but silently fails to create the environment. The job status description text in the UI denotes that an environment name of " " (empty space) is being used:

screenshot-2019-09-23-12_19 screenshot-2019-09-23-12_21

A lack of warning/error can possibly create confusion on the status of a job outcome.

Furthermore, the text could be considered misleading in that the job mentions an environment that does not exist.

This is somewhat similar in scope to #28220.

Tested in 12.2.5-ee.

Steps to reproduce

Create a branch and name it using an invalid character for environment names

  • a+b

.gitlab-ci.yml:

stages:
  - test

x:
  stage: test
  environment:
    name: test/${CI_COMMIT_REF_NAME}
  script:
    - env

What is the current bug behavior?

Pipeline succeeds, but no environment is created and no warning/error is output in the UI.

What is the expected correct behavior?

GitLab is working as expected for the most part, but does silently fail to create the environment. It should be noted, GitLab yaml linter does correctly emit a warning when manually setting environment:name to an invalid string. This bug is only relevant when CI variables cause the name to include an invalid character.

Relevant logs and/or screenshots

No errors are logged.

Possible fixes

I don't see how GitLab yaml linter would be able to output any warnings or errors when using a CI variable (e.g. $CI_COMMIT_REF_NAME), but the job page description could possibly emit a warning when the environment fails to create after the job run in this instance.

Edited Aug 28, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading