Gitlab Registry Tag, How to get latest in CI/CD pipeline

Hi everyone,I hope you’re all having a day filled with successful deployments and error-free scripts!

I have a question regarding Gitlab Registry

in a ci/cd pipeline, i need to get the latest pushed tag in a project registry
the container registry is in another repo

im struggling on how to get the latest pushed tag because i couldn’t find any useful docs about it

i tried using gitlab registry api but when listing the tags the order is mixed (not from old to new, or new to old)

i thought maybe if i got the list of tags ordered i can use jq to fetch the value i want
but the order is random

is there a way to do an api call to get all tags from a registry with order from old to new or new to old

here is the call im using now :

curl --header "PRIVATE-TOKEN: token" "https://git.ex.ex/api/v4/projects/22/registry/repositories/5/tags"

or is there another way to do so using ci/cd pipelines ?

Hi @ossamasgr

using GitLab API you need to get list of tags and then go through all of them using Container Registry API | GitLab where you get the created_at field.

1 Like