Delete CI artifacts/builds

Is it possible to delete old builds in Gitlab CI? I tested a few things and have now about 20 builds that are useless (most are failed anyway). It also shows stages that I don’t have anymore which kinda clutters the Pipelines page and some of the uploaded artifacts are a bit big.

I wasn’t able to find any documentation on this, only that disabling CI in the settings doesn’t remove the builds.

Using Gitlab 8.10 Community hosted on Gitlab.com

Thank you!

PS: Same question posted on StackOverflow. Didn’t get an answer there and thought this might be a better place for this question.

This question has been answered on StackOverflow, I’m quoting it here again:

Fairy:

There is currently no option in the GUI to completely get rid of a build other than expunge related data from the build. (The erase option in the build)

If you would have a local installation you could modify the database directly but I would advise caution. (I’ll put the guide here for completeness sake)

Login to the GitLab database. If you use the default PostgreSQL :
sudo -u gitlab-psql /opt/gitlab/embedded/bin/psql -h /var/opt/gitlab/postgresql -d gitlabhq_production
Check if there is a table ci_builds. For pSQL: \dt
Delete the builds with normal SQL. For example: DELETE FROM ci_builds WHERE id = 2
(Optional) If you want to cleanup a list of commits which triggered a build you need to midify the table ci_commits.

With the erase button I was able to remove the big artifacts and I realized that in each Pipeline page it only shows the build stages of the builds that are visible. So after a few builds my clutter problem will be gone as well.