Skip to content

Instantly share code, notes, and snippets.

@anakaiti
Created June 6, 2022 13:36
Show Gist options
  • Save anakaiti/b9c7ad4302ba6b48bb655b519d4e89b5 to your computer and use it in GitHub Desktop.
Save anakaiti/b9c7ad4302ba6b48bb655b519d4e89b5 to your computer and use it in GitHub Desktop.
Remove all offline gitlab runners in a group
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