Delete or reset Gitlab CI builds

Johannes Bildstein picture Johannes Bildstein · Jul 24, 2016 · Viewed 15.3k times · Source

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 by Gitlab.com)

Answer

Fairy picture Fairy · Aug 2, 2016

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)

  1. 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
    
  2. Check if there is a table ci_builds. For pSQL: \dt

  3. Delete the builds with normal SQL. For example: DELETE FROM ci_builds WHERE id = 2

  4. (Optional) If you want to cleanup a list of commits which triggered a build you need to midify the table ci_commits.