Created
June 6, 2022 13:36
-
-
Save anakaiti/b9c7ad4302ba6b48bb655b519d4e89b5 to your computer and use it in GitHub Desktop.
Remove all offline gitlab runners in a 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
import os | |
import requests | |
import urllib.parse | |
GITLAB_AUTH_TOKEN = '' | |
GROUP_ID = '' | |
headers = {"PRIVATE-TOKEN": GITLAB_AUTH_TOKEN} | |
r = requests.get( | |
f"https://gitlab.com/api/v4/groups/{GROUP_ID}/runners?status=offline", headers=headers) | |
runner_data = r.json() | |
for runner in runner_data: | |
r = requests.delete( | |
f"https://gitlab.com/api/v4/runners/{runner['id']}", | |
headers=headers, | |
) | |
if not r.ok: | |
print("Encountered an error deleting runner from project:", r.json()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment