Add reference to component context for interpolation
What does this MR do and why?
This change introduces the reference field to the component context,
making it available for interpolation in CI/CD component templates.
The reference field represents the original version reference used
when including a component (e.g., '1.0.0', '0.1', '~latest', or a SHA),
while the existing version field continues to represent the resolved
semantic version from the catalog resource.
This distinction is important because:
-
versionis resolved to a catalog version (e.g., '0.1' resolves to '0.1.2') -
referencepreserves the original reference as specified (e.g., '0.1' stays '0.1') - For non-catalog projects or SHAs,
versionis nil whilereferencecontains the value
This feature is behind the ci_component_context_interpolation feature flag.
References
| Ref | Link |
|---|---|
| Issue | Components - Allow interpolation to use local c... (#438275) |
| Step 1 | Prepare CI interpolation logic for component co... (!205999 - merged) |
| Step 2 | Implement name and sha component context interp... (!206183 - merged) |
| Step 3 | Implement version component context interpolation (!208965 - merged) |
| Step 4 | <<-- HERE-->> |
| Step 5 | Documentation |
How to test
Create a catalog resource project with these files:
templates/component-1.yml:
spec:
component: [name, sha, version, reference]
inputs:
compiler:
default: gcc
optimization_level:
type: number
default: 2
job_name:
---
test-$[[ inputs.job_name ]]:
script:
- echo "Building with $[[ inputs.compiler ]] and optimization level $[[ inputs.optimization_level ]]"
- echo "Component $[[ component.name ]] / $[[ component.sha ]] / $[[ component.version ]] / $[[ component.reference ]]"
Create .gitlab-ci.yml:
include:
# Test with full version
- component: gdk.test:3000/components/component-test-project-for-interpolation/component-1@1.0.0
inputs:
job_name: "full-version"
rules:
- if: $CI_COMMIT_TAG == null
# Test with shorthand version (should resolve to 1.0.2)
- component: gdk.test:3000/components/component-test-project-for-interpolation/component-1@1.0
inputs:
job_name: "partial-version"
rules:
- if: $CI_COMMIT_TAG == null
# Test with ~latest (should resolve to latest version 1.0.2)
- component: gdk.test:3000/components/component-test-project-for-interpolation/component-1@~latest
inputs:
job_name: "latest-version"
rules:
- if: $CI_COMMIT_TAG == null
# Test with SHA (version should be nil)
- component: gdk.test:3000/components/component-test-project-for-interpolation/component-1@$CI_COMMIT_SHA
inputs:
job_name: "sha-version"
rules:
- if: $CI_COMMIT_TAG == null
create-release:
image: registry.gitlab.com/gitlab-org/cli:latest
tags: [docker]
script: echo "Creating release $CI_COMMIT_TAG"
rules:
- if: $CI_COMMIT_TAG
release:
tag_name: $CI_COMMIT_TAG
description: "Release $CI_COMMIT_TAG of components repository $CI_PROJECT_PATH"
Create releases with tags 1.0.0 and 1.0.2.
Run a pipeline
With FF ci_component_context_interpolation enabled
With FF ci_component_context_interpolation disabled
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.







