I have registered a personal GitLab runner several months ago, which I no longer use. How do I completely delete it so that it does not show up on my GitLab CI/CD settings page?
To do this, open the Command Prompt as shown below. Browse to the following location where the executable resides: C:\GitLab-Runner . – Run the command GitLab-runner stop (This will ensure the service stops running). As you can see above, you can now choose to delete the folder in which the GitLab-Runner resided.
To disable shared runners for a project: Go to the project's Settings > CI/CD and expand the Runners section. In the Shared runners area, select Enable shared runners for this project so the toggle is grayed-out.
First, go to the GitLab settings page and find the token (e.g. 250cff81
in the image below) and the id (e.g. 354472
in the image below) of the GitLab runner which you wish to delete.
gitlab-runner
CLI to unregister the runnerIf you have access to the machine which was used to register the GitLab runner, you can unregister the runner using the following command, where you replace {TOKEN}
with the token of your GitLab runner (e.g. 250cff81
in the example above).
gitlab-runner unregister --url https://gitlab.org/ --token {TOKEN}
If you no longer have access to the machine which was used to register the runner, or if the runner is associated with multiple projects, you can use the following Python script. Set RUNNER_ID
to the id of your runner (e.g. 354472
in the example above) and GITLAB_AUTH_TOKEN
to a GitLab token which you can generate from your profile page.
import os
import requests
GITLAB_AUTH_TOKEN = ...
RUNNER_ID = ...
headers = {"PRIVATE-TOKEN": GITLAB_AUTH_TOKEN}
r = requests.get(f"https://gitlab.com/api/v4/runners/{RUNNER_ID}", headers=headers)
runner_data = r.json()
for project in runner_data.get("projects", []):
r = requests.delete(
f"https://gitlab.com/api/v4/projects/{project['id']}/runners/{RUNNER_ID}",
headers=headers,
)
if not r.ok:
print("Encountered an error deleting runner from project:", r.json())
r = requests.delete(f"https://gitlab.com/api/v4/runners/{RUNNER_ID}", headers=headers)
if not r.ok:
print("Encountered an error deleting runner:", r.json())
List runners to get their tokens and URLs:
sudo gitlab-runner list
Verify with delete option specifying runner's token and URL:
sudo gitlab-runner verify --delete -t YMsSCHnjGssdmz1JRoxx -u http://git.xxxx.com/
Here's one-liner to remove offline runners (for GitLab 14.5
):
curl --header "PRIVATE-TOKEN: <private_token>" "https://<your-instance-address>/api/v4/runners/all?scope=offline&per_page=100" | jq '.[].id' | xargs -I runner_id curl --request DELETE --header "PRIVATE-TOKEN: <private_token>" "https://<your-instance-address>/api/v4/runners/runner_id"
You might run this more than once if you have more than 100 offline runners (per_page=100
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With