Created
June 22, 2021 19:17
-
-
Save phgeraldeli/e27ce4fe0249a17edc893131acb3e732 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get all group owners from gitlab | |
MY_ACCESS_TOKEN=$1 | |
curl -s --location --request GET 'http://gitlab.intranet/api/v4/groups' --header "PRIVATE-TOKEN: ${MY_ACCESS_TOKEN}" -o file.txt | |
grep -Po '"id":\d+' file.txt | cut -d: -f2 > ids.txt | |
grep -Po 'web_url":[^,]+' file.txt > names.txt | |
for X in $(cat ids.txt); do | |
curl -s --location --request GET "http://gitlab.intranet/api/v4/groups/${X}/members/" --header "PRIVATE-TOKEN: ${MY_ACCESS_TOKEN}" > members.json | |
echo ${X} - $(head -1 names.txt) | |
sed -i 1d names.txt | |
sed -i 's/]\[/,/g' members.json | |
python -m json.tool members.json | grep -A6 -P '(access_level": 50)' | grep -P '("name|access_level)' | |
done > owner_members.txt | |
rm -f members.json ids.txt file.txt names.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment