Skip to content

Instantly share code, notes, and snippets.

@rachejazz
Created August 22, 2022 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rachejazz/50bc08c8edada7945ce603a7718ea278 to your computer and use it in GitHub Desktop.
Save rachejazz/50bc08c8edada7945ce603a7718ea278 to your computer and use it in GitHub Desktop.
Gets list of all users with access levels across gitlab organisation
#!/bin/bash
#Usage:
#./getusers.sh <TOKEN> <GROUP ID>
#
i=1
rm users ids final
while [[ $i -ne 10 ]]
do
curl -s --header "PRIVATE-TOKEN: $1" "https://gitlab.com/api/v4/groups/$2/projects?simple=true&order_by=last_activity_at&pagination=keyset&per_page=100&page=$i" | jq -r '.[]|.id' > ids
while read -r line
do
echo "for project $line"
curl -s --header "PRIVATE-TOKEN: $1" "https://gitlab.com/api/v4/projects/$line/members/all?per_page=100&page=1" | jq -r '.[]|.username' >> users
done < ids
let "i++"
done
cat users | sort | uniq > final
rm users ids
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment