How to Use a Reusable CI/CD Component in GitLab CI
GitLab CI/CD Components are versioned, parameterized pipeline building blocks you pull in with include:component.
Use include: - component: with the component path and a version, passing parameters under inputs:. Components live in the CI/CD Catalog and are versioned by tag.
Include a component with inputs
The component adds its jobs to your pipeline; inputs: parameterize it (e.g. the node version).
.gitlab-ci.yml
include:
- component: $CI_SERVER_FQDN/my-group/node-ci/build@1.2.0
inputs:
node_version: "20"
run_tests: true
stages: [build, test]Gotchas
- Pin a component to a version tag (
@1.2.0), not@main, so a catalog change cannot silently alter your pipeline. - Components use typed
inputs:(declared in the component'sspec:); passing an unknown input fails validation. - This differs from
include:template(GitLab-shipped) andextends:(in-file reuse) - components are versioned and parameterized.
Related guides
How to Use a Reusable Workflow in GitHub ActionsShare CI logic across repos with a reusable GitHub Actions workflow - define workflow_call inputs and secrets…
How to Set Up a Monorepo Pipeline in GitLab CISet up a monorepo pipeline in GitLab CI with rules:changes per component and parent-child pipelines via trigg…