How to list all projects in Gitlab

Albert De La Fuente Vigliotti

I have tested the glab tool and apparently there should be a way to list all projects but I couldn’t do it. Maybe the arch linux package is still not updated and there is no aur package, so… I searched for an alternative and luckily there is always a python tool/module to help us out… so I installed python-gitlab-cli. Setup is pretty straight forward, just read the docs.

Alternatively you can install the AUR package with:

pacaur -S python-gitlab

The only consideration are:

  • Use a pass wrapper to asymmetrically GPG decrypt the token (for security)
  • Use a timeout higher than 5 if your connection sucks (as mine)

This is how my ~/.python-gitlab.cfg file looks like:

[global]
default = gitlab
ssl_verify = true
timeout = 5

[gitlab]
url = https://gitlab.com
private_token = helper: ~/bin/pass-python-gitlab.sh
api_version = 4
timeout = 30

Once configured, the magic line to list all the repos alphabetically is:

gitlab -o json project list --owned=1 --all | jq .[].path_with_namespace
gitlab -o json project list --owned=1 --all --per-page 300 | jq .[].path_with_namespace

References #

How do I access gitlab api using python-gitlab? - Stack Overflow #