Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save michaelkebe/3e4f3d8e8d61dc996611b356c3e52511 to your computer and use it in GitHub Desktop.
Save michaelkebe/3e4f3d8e8d61dc996611b356c3e52511 to your computer and use it in GitHub Desktop.
Script to add gitlab users from one group to another
#!/bin/sh
GITLAB_URL="https://git.acme.com"
PRIVATE_TOKEN="abcde-fghijklmnop"
FROM_GROUP_ID=$1
TO_GROUP_ID=$2
ACCESS_LEVEL=40
USERIDS_OF_GROUP=$(curl -s --header "PRIVATE-TOKEN: $PRIVATE_TOKEN" $GITLAB_URL/api/v4/groups/$FROM_GROUP_ID/members| jq ".[].id")
for USERID in $USERIDS_OF_GROUP
do
curl -s --header "PRIVATE-TOKEN: $PRIVATE_TOKEN" --data "user_id=$USERID&access_level=$ACCESS_LEVEL" $GITLAB_URL/api/v4/groups/$TO_GROUP_ID/members
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment