wiki/content/20220212123754-gitlab.md

961 B

id title
d178ca6b-0d1a-4b6f-9285-22724e98ba2b Gitlab

Troubleshooting

Artifacts1

Delete artifacts older than a specific date

From gitlab-rails console:

builds_to_clear = builds_with_artifacts.where("finished_at < ?", 1.week.ago)
builds_to_clear.find_each do |build|
  build.artifacts_expire_at = Time.now
  build.erase_erasable_artifacts!
end

The same can be done to include logs as well:

builds_to_clear = builds_with_artifacts.where("finished_at < ?", 1.week.ago)
builds_to_clear.find_each do |build|
  print "Ci::Build ID #{build.id}... "

  if build.erasable?
    build.erase(erased_by: admin_user)
    puts "Erased"
  else
    puts "Skipped (Nothing to erase or not erasable)"
  end
end

Expiration cron job

In /etc/gitlab/gitlab.rb enable gitlab_rails['expire_build_artifacts_worker_cron'] = "*/7 * * * *".

Footnotes