mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-22 03:26:22 +00:00
46 lines
978 B
Markdown
46 lines
978 B
Markdown
---
|
|
date: 2022-02-12
|
|
id: d178ca6b-0d1a-4b6f-9285-22724e98ba2b
|
|
title: Gitlab
|
|
---
|
|
|
|
# Troubleshooting
|
|
|
|
## Artifacts[^1]
|
|
|
|
### Delete artifacts older than a specific date
|
|
|
|
From `gitlab-rails console`:
|
|
|
|
``` ruby
|
|
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:
|
|
|
|
``` ruby
|
|
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
|
|
|
|
[^1]: <https://docs.gitlab.com/ee/administration/job_artifacts.html>
|