Skip to content

Instantly share code, notes, and snippets.

@sebastianha
Last active December 2, 2019 10:51
Show Gist options
  • Save sebastianha/bfb9e2f82a9b94a2fc7ac4d1158492b7 to your computer and use it in GitHub Desktop.
Save sebastianha/bfb9e2f82a9b94a2fc7ac4d1158492b7 to your computer and use it in GitHub Desktop.
Remove all shared groups and members from projects
#!/bin/bash
API_TOKEN="<TOKEN>"
API_URL="https://gitlab.com/api/v4"
GL_GROUPS=( 16 27 33 36 )
for PROJECT_ID in {1..260}; do
echo "Working on Project: $PROJECT_ID"
for GL_GROUP in "${GL_GROUPS[@]}"; do
echo "Removing group: $GL_GROUP"
curl -s --request DELETE --header "PRIVATE-TOKEN: ${API_TOKEN}" "${API_URL}/projects/${PROJECT_ID}/share/${GL_GROUP}" | jq "."
done
for GL_MEMBER in `curl -s --header "PRIVATE-TOKEN: ${API_TOKEN}" "${API_URL}/projects/${PROJECT_ID}/members" | jq ".[]|.id"`; do
echo "Removing member: $GL_MEMBER";
curl -s --request DELETE --header "PRIVATE-TOKEN: ${API_TOKEN}" "${API_URL}/projects/${PROJECT_ID}/members/${GL_MEMBER}" | jq "."
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment