Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Generate a CSV dump of project information from GitLab
# This script can be used as a starting point for generating a spreadsheet of
# GitLab projects, with their properties, from an existing GitLab instance
# You must set a GitLab access token via the GITLAB_TOKEN env variable
# Invoke with ./ <gitlab hostname>
echo "path,archived,namespace_kind" > ${FILENAME}
for i in $(seq 1 100); do
echo ">> Fetching page ${i}.."
curl --silent --fail \
-o - \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${GITLAB_TOKEN}" \
"https://${1}/api/v4/projects?per_page=100&page=${i}" \
| jq -e -r ".[] | [.path_with_namespace, .archived, .namespace.kind] | @csv" \
if [ $? -ne 0 ]; then
echo ">> Exiting after $i pages, $(wc -l $FILENAME) written to ${FILENAME}";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment