Skip to content
Latchkey

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's spec:); passing an unknown input fails validation.
  • This differs from include:template (GitLab-shipped) and extends: (in-file reuse) - components are versioned and parameterized.

Related guides

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