Clean Up Gitlab Registry

Hi there,

what are the settings for the cleanup policy to achieve the following:

Preserve the recent 10 images with tag: semver
Example: imagename-example:1.0.0
Calling it “release-tags”

Preserve the recent 10 images with tag: sha-shortshacommit
Example: imagename-example:sha-d729d11
Calling it “dev-tags”

Delete the rest (Time doesnt really matter, optional remove older than 30 days)

We got the regexes right. While testing with the settings (see picture below),
we tested with keep 1 tag per image (not 10) because its testing :slight_smile: ,
we realized that it keeps more than 1 image of both “release-tags” and “dev-tags”.

We want to achieve the common scenario where there will be multiple “dev-tags” most of the time more recent then the “release-tags” but keep the 10 recent of both of them.

What are the settings for that?

Thx in advance!

Hi,

the regex looks complicated, can you post the text string enclosed in backticks as code? Maybe it is matching “too much”.

How did you verify this? Can you share the commands / screenshots you did in the process?

Also, which GitLab version are you using - 14.0 or earlier?

Cheers,
Michael

1 Like

Thx for your reply!

I am pretty sure the regex is working but sure here you go:

We are using SaaS of Gitlab.com so your uptodate release.
I don’t have any screenshot but we will reproduce the scenario in the next days again if it helps
but I can remember it:

With the settings from screenshot above the registry after a cleanup looked like this:
imagenamex:2.0.0
imagenamex:1.1.1
imagenamex:1.0.0
imagenamex:sha-21aedw41
imagenamex:sha-2d3aw564
imagenamex:sha-453aw3sd

I also can remember that images with not matching tags were cleaned up.
But we would have expected that one image per tag remains like so:
imagenamex:2.0.0
imagenamex:sha-21aedw41

Thats the desired state keep the most recent one (screenshot: 1 tag per imagename) of EACH tag which matches the keep tags regex.
Shouldn’t it work this way?

Or in other words, “Keep tags matching” is cleaned up or limited by which option?
If I understand the 9 points right: GitLab Container Registry | GitLab

It isn’t limited/cleaned up at all. But this is a common scenario. Release Version counting up which you want to retain maybe the last 10-20 Releases are enough. And the fast moving develope tags -sha between the releases which in case you want to rollback so the 10-15 recent ones are enough and the rest can be cleaned, as well.

Isnt that supported?