Support CI include:components version `~latest` for all projects
What does this MR do and why?
In !115756 (merged), we introduced the version keyword ~latest
when including components in a Ci config. This keyword was limited to projects that were marked as Catalog Resources only. In this MR, we are enabling its use for all projects regardless of the project type.
The ~latest
version is defined as: a special moving target version that points to the most recent released tag
.
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: Components support ~latest in all project (#413595 - 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
- Create a new branch named
branch-v0.1
with the following content in/components/component-1/template.yml
:
component-1-v0.1:
script: echo
- Create a new branch named
branch-v0.2
with the following content in/components/component-1/template.yml
:
component-1-v0.2:
script: echo
- Create two tags:
- Create a tag named
v0.1
for branchbranch-v0.1
- Create a tag named
v0.2
for branchbranch-v0.2
- Create a new release for tag
v0.1
for the current date.
- Update your
.gitlab-ci.yml
file with the following content (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 merged yaml/full configuration 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.
-
(Optional) You can experiment with changing the release date to ensure that the
@~latest
keyword only retrieves the latest release tag. -
(Optional) You can also observe that if you mark the project as a catalog resource, the result is the same.
::Ci::Catalog::Resource.create(project: Project.find(<project_id>))
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 #413595 (closed)