Cleanup policy for tags to support dynamic names
Release notes
If you are using CI to build and publish container images, chances are you are naming them dynamically. For example, using GitLab's pre-defined environment variables you could have two different images: mitar/example/branch/<branch name>:latest
and mitar/example/pipeline/<pipeline id>:latest
.
The problem is that GitLab's cleanup policies only allow you to remove images based on tag name and has not supported dynamic names. This has forced many of you to manually remove these images using the container registry API or not removing them and spending more on storage costs.
Not anymore. Moving forward when managing your project's policies you can choose whether you want your regex applied to the tag name or the full path. If you are interested in contributing and helping to improve this product, documentation and examples are great ways to help. (because who is good at regex?)
Problem to solve
The cleanup policies for tags do not support dynamic container image names. This is problematic for users that use GitLab's pre-defined environment variables to dynamically name their branch and pipeline specific container images. The impact of this problem is that you are paying more for storage or it's just harder to find your container images in the UI.
Proposal
Support dynamic image names by allowing the user to select if the regex inputted should match based on tag name only or the full path. This will work with both the API and the user interface. The default state of the checkbox (or other UI moment) will be set to only the tag name so that all the regex already implemented will continue to work and we offer a new ability that users can turn on if they want to include the path.
Documentation
- Update the documentation to make it clear that the current policy only works on tag name
-
regex examples are like
v.+
. I think they should be^v.+
and formaster
they should be^master$
Metrics
Measure the number of policies using tag name only vs. the full path.