Created
June 21, 2018 09:16
-
-
Save matsskoglund/c0a5e01151a2fc7d96e91b03ecdad2eb to your computer and use it in GitHub Desktop.
Remove all Gitlab runners for a user and group
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 | |
PAMTOKEN=YoUrPaMtOkEn | |
USERNAME=username | |
GROUPNAME=groupname | |
echo Disable all runners for a user | |
curl -s --request GET --header "PRIVATE-TOKEN: $PAMTOKEN" "https://gitlab.com/api/v4/users/$USERNAME/projects"|jq '.[].id'|while read -r line1; do command curl -s --header "PRIVATE-TOKEN: $PAMTOKEN" "https://gitlab.com/api/v4/projects/$line1/runners"|jq '.[].id'|while read -r line; do command curl --request DELETE --header "PRIVATE-TOKEN: $PAMTOKEN" "https://gitlab.com/api/v4/projects/$line1/runners/$line"; done;done | |
echo Disable all runners for a group | |
curl -s --request GET --header "PRIVATE-TOKEN: $PAMTOKEN" "https://gitlab.com/api/v4/groups/$GROUPNAME/projects"|jq '.[].id'|while read -r line1; do command curl -s --header "PRIVATE-TOKEN: $PAMTOKEN" "https://gitlab.com/api/v4/projects/$line1/runners"|jq '.[].id'|while read -r line; do command curl --request DELETE --header "PRIVATE-TOKEN: $PAMTOKEN" "https://gitlab.com/api/v4/projects/$line1/runners/$line"; done;done | |
echo Delete all runners that are not on several projects | |
curl -s --header "PRIVATE-TOKEN: $PAMTOKEN" "https://gitlab.com/api/v4/runners"|jq '.[].id'|while read -r line; do command curl --request DELETE --header "PRIVATE-TOKEN: $PAMTOKEN" "https://gitlab.com/api/v4/runners/$line"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment