Remove all job logs and artifacts in your GitLab instance

Use with caution. This is a gitlab-rails console script that removes all job logs and artifacts. Good for small test instances when you need to free up some space.

admin_user = User.find_by(username: 'root')
 Ci::Build.find_each do |build|
   print "Ci::Build ID #{}… "
   if build.erasable?
     build.erase(erased_by: admin_user)
     puts "Erased"
     puts "Skipped (Nothing to erase or not erasable)"

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.