How to Include Remote and Template YAML in GitLab CI/CD
include merges configuration from local files, other projects, remote URLs, or GitLab templates into your pipeline.
Use include with local, project, remote, or template. The included config is merged before the pipeline is created, so jobs and defaults compose across files.
Steps
- Use
include:localfor files in the same repo. - Use
include:projectwithrefandfileto pull from another project. - Use
include:remotefor a URL orinclude:templatefor a GitLab template.
Pipeline
.gitlab-ci.yml
include:
- local: '/ci/test.yml'
- project: 'my-group/ci-templates'
ref: v2
file: '/build.yml'
- remote: 'https://example.com/ci/lint.yml'
- template: 'Security/SAST.gitlab-ci.yml'Gotchas
- Pin
include:projectto aref(tag or SHA) so an upstream change cannot break your pipeline unexpectedly. - A remote include must be reachable when the pipeline is created or it fails to compile.
Related guides
How to Use extends and YAML Anchors in GitLab CI/CDCut duplication in GitLab CI/CD with extends to inherit from a hidden template job, and YAML anchors to reuse…
How to Use CI/CD Components in GitLab CI/CDReuse versioned pipeline building blocks in GitLab CI/CD with components, including a component by its path a…