Hello everyone,
I’ve three tags in my container registry on gitlab :
[
{
"name": "1.0.0",
"path": "myproject/docker/my-image:1.0.0",
"location": "registry.example.com/myproject/docker/my-image:1.0.0"
},
{
"name": "1.0.0-beta.1",
"path": "myproject/docker/my-image:1.0.0-beta.1",
"location": "registry.example.com/myproject/docker/my-image:1.0.0-beta.1"
},
{
"name": "latest",
"path": "myproject/docker/my-image:latest",
"location": "registry.example.com/myproject/docker/my-image:latest"
}
]
I’m trying to delete image tags using the GitLab API, but I want to keep certain tags based on a regex pattern. Here’s the command I’m using:
curl --request DELETE \
--data 'name_regex_keep=([0-9]+.[0-9]+.[0-9]+|latest)' \
--data 'name_regex_delete=.*' \
--header "PRIVATE-TOKEN: $ACCESS_TOKEN" \
"$GITLAB_URL/api/v4/projects/$PROJECT_ID/registry/repositories/$REPOSITORY_ID/tags"
According to the regex, it should keep tags that match the pattern x.y.z (e.g., 1.0.0) as well as latest. However, after executing the command, only the latest tag remains.
Could someone help me understand why the 1.0.0 tag is being deleted despite the regex pattern intended to keep it? Any insights or suggestions would be greatly appreciated.