Middle+
What is the difference between include local, include remote, and include template in GitLab CI?
sobes.tech AI
Answer from AI
In GitLab CI, the include directive allows you to include additional configuration files for the pipeline. There are three main options:
-
include: local
- Includes a file from the same repository where the
.gitlab-ci.ymlis located. - The path is specified relative to the root of the repository.
- Used for splitting configuration within a single project.
- Includes a file from the same repository where the
-
include: remote
- Includes a file via URL from an external source (e.g., from another server or a public repository).
- Allows using shared templates or configurations stored outside the current repository.
-
include: template
- Includes predefined GitLab templates that come with GitLab.
- For example, templates for popular languages, frameworks, or tools.
- Simplifies setting up common pipelines.
Example usage:
include:
- local: 'ci-templates/build.yml'
- remote: 'https://example.com/ci-templates/deploy.yml'
- template: 'Security/SAST.gitlab-ci.yml'
Thus, local is for internal files, remote for external URLs, and template for built-in GitLab templates.