Gitlab.com SaaS has a hierarchical group project structure which can be a pain to navigate when you simply want a list of all of your docker container registry paths within it. One way to quickly fetch all of this information is via the Gitlab API

  1. Simply generate a Group Access Token at: https://gitlab.com/groups/<your-group-name>/-/settings/access_tokens

  2. Then you can use that token to run the following query and output the output to json file:

GROUP_ACCESS_TOKEN=# Generate one with registry read here https://gitlab.com/groups/<your-group-name>/-/settings/access_tokens
GROUP_ID=# find group id listed on the groups general settings page
curl --header "Content-Type: application/json" --header "PRIVATE-TOKEN: $GROUP_ACCESS_TOKEN" "https://gitlab.com/api/v4/groups/$GROUP_ID/registry/repositories" > registrylist.ugly.json
  1. Lastly to format that json more readably:
python3 -m json.tool registrylist.ugly.json > registrylist.json
  1. Now you have your registrylist.json and don't have to click through a million gitlab.com projects and menus to figure out what projects have container images in them.

Next Post Previous Post