'Gitlab CI, include rule's if condition is ignored
I've following in .gitlab-ci.yml
:
include:
# env variables
- local: test.yml
rules:
- if: $CI_BUILD_REF_NAME == "dev"
- local: int.yml
rules:
- if: $CI_BUILD_REF_NAME == "qa"
- local: prod.yml
rules:
- if: $CI_BUILD_REF_NAME == "master"
Included files have:
# test.yml
variables:
ENV: "test"
# int.yml
variables:
ENV: "int"
# prod.yml
variables:
ENV: "prod"
When the job is executed, the rules
are ignored and all files are included, so the $ENV
variable always resolves to prod
no matter what value $CI_BUILD_REF_NAME
has, since the last included file was prod.yml
. What went wrong?
Gitlab server version is 13.9
Solution 1:[1]
You can only use the variables that are part of this list - use-variables-with-include
CI_BUILD_REF_NAME cannot be used to evaluate rules in include
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Kaish kugashia |