variables not handled in static linter include: blocks
Summary
- When using the
$CI_COMMIT_REF_NAMEpredefined variable inside anincludeblock in a CI configuration, CI linter does not interpolate the variable and linters a different, probably wrong, configuration.
Steps to reproduce
- Create a new project
- Create a
.gitlab-ci.ymlfile like this:
stages:
- build
hello_world:
stage: build
script:
- echo $CI_COMMIT_REF_NAME
include:
- remote: "https://myrepositoryofthings.com/example?branch_name=$CI_COMMIT_REF_NAME&ext=.yml"
- Note that linter complains that the url the
https://myrepositoryofthings.com/example?branch_name=&ext=.ymlcannot be found, which is missing the variable value, however for running the variable actually is inserted.
This GitLab CI configuration is invalid: Remote file could not be fetched because URL 'https://myrepositoryofthings.com/example?branch_name=&ext=.yml' is blocked: Host cannot be resolved or invalid! Learn more
Note
using an api makes it easily observable, but actually the bug is worse for other includes, as then the linter silently will use a different configuration than the runner. I dont know about gitlab codebase, but i think it would be sensible to merge the configuration aggregation for both linter and runner?