Created
February 13, 2019 07:13
-
-
Save michaelkebe/3e4f3d8e8d61dc996611b356c3e52511 to your computer and use it in GitHub Desktop.
Script to add gitlab users from one group to another
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/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