GitLab: Clean Up Pipes
If you have multiple projects running numerous builds, your job history will grow, even when you chop off repository branches. Let's discuss a few methods to keep it tidy.
The most obvious and (there should be a rule for this) the least effective way is manual deletion. It takes a few steps to complete such a minute action:
- In the navigation pane of your GitLab project, locate the Build/Jobs page and find the job you want to drop.
- Click on the Status icon in the first column.
- Now you have access to the job instance control. Three icons in the header allow you to delete the job, edit job variables, and restart the instance.

- As it wasn't hard enough to get there, the system will ask you to confirm your intentions.
When I've jumped through the hoops for the first time, I realize that it may take a few days to delete about two hundred jobs this way. A quick discussion with the local AI led me to the GitLab CLI utility, glab. After a simple installation and configuration, you get a tool that allows you to do magic.

The most useful parameters are:
- Delete by time (--older-than time-period) allows you to delete any job that is older than the specified time interval.
$ cd ~/my-project-folder/
$ glab ci delete --older-than 48h
- Delete by state (--status) will delete any job that matches the provided status.
$ glab ci delete --status canceled
Of course, you can combine filters and, for instance, delete all failed jobs older than a week.
And finally, for the hands-free CI/CD pipeline control, you may choose the automated job purging. It's as easy as it sounds:
- Open your repository settings
- Locate the CI/CD Settings section
- Expand the CI/CD group
- Specify the duration you want to retain your pipeline executions in the Automatic Pipeline Cleanup field.

To wrap up:
- Configure automated pipeline cleanup, especially for long-term history (two weeks or more).
- Use GitLab CLI utility to perform mass pipeline cleanups.
- Use the GitLab UI to manually delete job instances, especially if you have all time in the world.