I’m trying to use “include” in my gitlab-ci.yml to pull in an external file with shared code. In a job, I want to use “extends” to consume the template defined in the file pulled in with include. However, when I push this, the linter fails, indicating that the key defined in the “extends” section is not found. If I pull the content from the external file into the main gitlab-ci.yml file, it passes linting fine.
The docs indicate that included files are merged in before the other steps are done, so I’m not sure why this isn’t working.
Here is the gitlab-ci.yml file:
image: docker
include:
- 'https://myrepo.com/build.yaml'
stages:
- build
- test
- deploy
buildit:
extends: .build_template
stage: build
Here is the build.yaml file:
.build_template:
services:
- docker:dind
script:
- echo "This is in the shared code."
And here is the error:
**Status:** syntax is incorrect
**Error:** buildit: unknown key in `extends`