Support `@~latest` version when including components
What does this MR do and why?
This MR adds support to allow the version to be specified as ~latest when including components. The ~latest version is defined as: a special moving target version that points to the most recent released tag. The target project must be an explicit catalog resource.
Note that when the project does not have a release, it displays a "content not found" error (similar to when any target version does not exist).
Solves: Backend: Support `@~latest` version when includ... (#390839 - closed)
How to set up and validate locally
- Enable the feature flag:
Feature.enable(:ci_include_components) - Create a project with a component.
Path: /components/component-1/template.yml
template.yml:
component-1:
script: echo
- Mark the project as a catalog resource in the Rails console.
::Ci::Catalog::Resource.create(project: Project.find(<project_id>))
- Create a new branch named
branch-v0.1with the following content in/components/component-1/template.yml:
component-1-v0.1:
script: echo
- Create a new branch named
branch-v0.2with the following content in/components/component-1/template.yml:
component-1-v0.2:
script: echo
- Go to Repository > Tags:
- Create a tag named
v0.1for branchbranch-v0.1 - Create a tag named
v0.2for branchbranch-v0.2
- Go to Deployments > Releases. Create a new release for tag
v0.1for the current date.
- Now go to CI/CD > Editor and update the content with the following YAML (adjusting the component path as needed):
include:
- component: gdk.test:3000/group-a/project-components-1/components/component-1@~latest
- Observe that there is no validation error.
And the "View merged YAML" content shows component-1-v0.1. Notice that it only retrieved the latest released tagged branch.
-
Commit the change and run the pipeline. It should succeed.
-
You can experiment with changing the release date to ensure that the
@~latestkeyword only retrieves the latest release tag. Also observe that if you remove all the releases or if the project is not a catalog resource, the following "content not found" error is displayed:
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #390839 (closed)




