Skip to content
Latchkey

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:local for files in the same repo.
  • Use include:project with ref and file to pull from another project.
  • Use include:remote for a URL or include:template for 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:project to a ref (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

Run this faster and cheaper on Latchkey managed runners. Start free →