Skip to main content

Things I've have learned: to bulk delete gitlab issues with glab

·2 mins

Last Saturday I saw one issue created by an unknown user in one of the repositories of our GitLab instance.

I made a screenshot, reported the user and deleted the issue, using GitLab’s Web interface. And didn’t think much about it.

After all it was one issue and four clicks after making the screenshot were not much work.

The message was rather long and looked very much like ChatGPT was tasked with writing an advertorial for a Python course.

Yesterday, I woke up to find that more than 80 issues were created in four minutes in another repository by another unknown user.

The were 100% spam, something about leaked videos.

I started deleting them by hand, but after a couple I realized that it was going to get tedious very fast.

I searched for an option to “bulk-delete” issues, but I only found the “bulk-edit” option.

Fortunately GLab, GitLab’s CLI tool also provides commands to manage issues, inside a repository, by just giving the id.

I’ve been using it to watch the pipelines running and spot problems before receiving an e-mail indicating that a pipeline has failed but providing almost no clue at what failed.

The only officially supported installation is with Homebrew.

After that you’ll need to authenticate either using OAuth, if you’re using GitLab.com or with a personal token if you are self-hosting.

Since the remaining issues in this repository were spam, and the ids started with 3 and went up to 80, I just needed one command to delete them all:

$ for id in `seq 3 80`; do glab issue delete $id; done