Skip to content

Powershell variable not recognized when setting environment name

PowerShell variables are flagged as a syntax error when setting a Environment Name. Variables in the url work fine.

Example script that works

Deploy:
 script:
  - 'echo "test"'
 environment:
  name: review
  url: http://$env:CI_COMMIT_REF_NAME.mydomain.com
 only:
   - branches

Example script that fails

Deploy:
 script:
  - 'echo "test"'
 environment:
  name: review/$env:CI_COMMIT_REF_NAME
  url: http://$env:CI_COMMIT_REF_NAME.mydomain.com
 only:
   - branches

Error: jobs:dev-deploy:environment name can contain only letters, digits, '-', '_', '/', '$', '{', '}', '.', and spaces

This might be loosely related to one of these, but I couldn't find one with the exact same problem https://gitlab.com/gitlab-org/gitlab-ce/issues/27436 https://gitlab.com/gitlab-org/gitlab-ce/issues/21995

Edited by John Spaetzel