Chapter 20Lesson 04~300 minutes

Includes, Templates, CI/CD Components, Component Catalog, and Reusable Pipeline Architecture: Diagnostics, Failure Modes, Security, and Performance

Diagnose mutable include drift, surprising merged configuration, broken component contracts, excessive component privilege, and unreviewed third-party dependencies while preserving evidence.

DiagnosticsMerge orderTrustSecretsPinningFailure analysis

Learning objectives

  • Diagnose include drift by resolving exact dependency identity.
  • Trace surprising behavior through the merged configuration and precedence order.
  • Handle incompatible input contracts as versioning failures.
  • Audit component runner/token/secret privilege and third-party provenance.
  • Repair the smallest cause and independently verify the effective configuration.
Availability baseline (verified 2026-08-22 against current GitLab 19.3 documentation). include, CI/CD inputs, CI/CD components, the CI/CD Catalog, and CI Lint are available on Free/Premium/Ultimate across GitLab.com, Self-Managed, and Dedicated. Component references must resolve on the same GitLab instance as the consuming project. The mandatory labs require only a disposable Free project and local configuration. Catalog publication is optional because publishing requires a catalog-enabled component project, appropriate project roles, a semantic-version release, and repository metadata. The current glab repo publish catalog command is experimental and therefore is not a mandatory production path.

1. Diagnostic sequence: preserve → scope → expand → resolve identity → inspect privilege → repair → verify

Reusable configuration failures are often blamed on “GitLab YAML.” That label is too broad. Preserve the pipeline ID/SHA and lint result, identify every include/component source, inspect the merged configuration, resolve each mutable reference to an exact commit/release, then inspect the runner/token/variable boundary before changing anything.

2. Failure mode: a moving include changes upstream and breaks consumers

Broken design:

include:
  - project: platform/ci-library
    ref: main
    file: /verify.yml

Yesterday the consumer passed; today it fails without a consumer commit. Preserve the consumer pipeline SHA and query the shared project’s current/history refs. The least destructive correction is to pin the last reviewed commit SHA, reproduce, then review the new library revision separately.

include:
  - project: platform/ci-library
    ref: 7b1c9f4d2a0e55d9b3f45d41715af3a8fbcde111
    file: /verify.yml

3. Failure mode: the source files look correct but the merged job is wrong

Because includes are recursive and the main file is merged after them, a value may be overridden far from where it was introduced. Use CI Lint with include_merged_yaml=true, then compare the final job with each source in precedence order.

jq --null-input --arg yaml "$(cat .gitlab-ci.yml)" '{content:$yaml}' \
| glab api --method POST "projects/$PROJECT_ID/ci/lint?include_merged_yaml=true" \
  --header "Content-Type: application/json" --input - \
  --jq '.merged_yaml'

Repair the narrowest owner of the unexpected value. Do not add a compensating override merely because it makes the next pipeline green.

4. Failure mode: component input contract changes incompatibly

A consumer that passes mode: strict may fail at pipeline creation if the component release removes that option or changes the input type. This is desirable fail-fast behavior compared with silently executing a different mode. Restore the previous compatible version, then migrate against a new major release or documented contract.

5. Failure mode: a reusable component receives more privilege than its task needs

A component that only checks source formatting should not run on a privileged runner, receive deployment credentials, or inherit broad environment access. Inspect the final job’s runner tags, variables, image, services, network calls, and API behavior. Move the job to a least-privilege runner/context rather than trusting component source alone.

6. Failure mode: third-party component or image was adopted without source review

Pause promotion. Identify the exact component revision and every transitive image/tool reference. Review the component source, release provenance, dependency pins, required credentials, and runner assumptions. If provenance cannot be established, replace it with a reviewed internal component or local fixture.

7. Failure mode: remote include content changes or disappears

If include:remote is unavoidable, use content integrity. A mismatched digest should fail pipeline creation—that is the safety mechanism, not an outage to bypass.

include:
  - remote: 'https://example.invalid/ci/base.yml'
    integrity: 'sha256-EXPECTED_BASE64_DIGEST'

Do not “repair” an integrity mismatch by copying the new hash before reviewing the changed content.

8. Intentionally broken example: later include changes the effective image

Suppose base.yml sets a reviewed image and team.yml later changes the same job:

include:
  - local: .gitlab/ci/base.yml
  - local: .gitlab/ci/team.yml

verify:
  script:
    - tool --version

CI Lint shows the final verify.image is the team override. Preserve that merged YAML, then decide whether the override is intentional. If not, remove it from team.yml; do not hide the evidence by setting yet another image in the main file.

9. Reliability and performance: reuse can multiply work silently

A component may add jobs, matrices, services, or broad rules. Adoption across many repositories can amplify runner demand and external API traffic. Inspect the expanded job count, rules, images, cache behavior, and schedule sources before rollout. Performance cost should be attributed to the reusable unit that introduced it.

10. Catalog publication diagnostics

If Catalog publication fails, verify project Catalog status, role, project description, root README, component files under templates/, semantic tag, and that the release is created through the CI release keyword. Do not fall back to an unrelated Releases API call if the Catalog publication contract requires the release job path.

11. If a component leaks a credential, response starts with revocation/rotation

Do not begin with Git history cleanup. Revoke or rotate the exposed credential, disable affected execution paths if necessary, preserve evidence, determine which pipelines/logs/artifacts received the value, then remove the leak from configuration/history according to your incident process.

12. Verification checklist

Evidence Question
Consumer pipeline ID + SHA Which immutable consumer revision failed?
Merged YAML What jobs and settings did GitLab actually compile?
Include/component provenance Which exact project/URL/component revision supplied each fragment?
Runner and runtime identity What code-execution and credential boundary did the reusable unit receive?
Before/after lint result Did the repair change only the intended effective configuration?

Knowledge check

A consumer breaks with no repository change. What is the first dependency question?

Why is adding a main-file override often a poor fix for an unexpected included value?

What should happen when include:integrity mismatches?

A formatting component runs on a privileged runner. What is the correct control?

A credential appears in a component job log. What is the first containment action?

Summary

Diagnose reusable CI failures from the final compiled state backward to provenance and privilege. Pin drift, preserve integrity failures, repair the source of precedence mistakes, version incompatible contracts, and keep reusable jobs on least-privilege runners with minimal credentials.

Official references

Primary sources used for the current GitLab 19.3 behavior taught in this lesson:

Next lesson

Prove the entire reusable dependency contract

The checkpoint lab extracts reusable configuration, predicts the merged job, records provenance, breaks one typed input contract safely, repairs it, and cleans up the synthetic dependency surface.

Keep the academy open

Support free, practical DevOps education.

Every lesson is designed to remain readable in a browser, downloadable from GitHub, and usable without a paid learning platform. Contributions help expand and maintain the curriculum.

Ethereum / ERC-20
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0Send only Ethereum/ERC-20 compatible assets to this address.