Review Apps not working for branches with invalid characters
Summary
When running a pipeline for a branch in Auto Devops, the Review App job does not receive the required environment variables, nor is an environment created if the branch has invalid characters (e.g. #)
Steps to reproduce
- Create a project with Auto DevOps enabled. I'm using a custom CI file, but using the default Review App job unaltered.
- Create a branch with an 'invalid' character, e.g. "#1234-test-branch"
- Check to see no environment is created and your Review App job fails due to missing environment variables, such as KUBE_NAMESPACE
Proposal A
Continue using CI_COMMIT_REF_NAME
but improve the messaging when the environment is not created, i.e. #21182 (closed)
The main benefit here is that we keep the obvioius correspondence between an environment name and the branch that created it. The main downside is that environments will still fail to get created for valid branch names.
Proposal B
Replace CI_COMMIT_REF_NAME
with CI_COMMIT_REF_SLUG
in the review environment names in the deploy template.
Unfortunately, this is a breaking change because it can cause some review environments to get orphaned and duplicate review apps to get deployed for some merge requests. The ones affected would be:
- branches with names longer than 63 characters
- branch names containing
/
Another downside is that it is more difficult to determine the branch from the environment name (but this link also exists through the deployment job).
The upside is that environments will never fail to be created.