Reputation: 701
We have a self-hosted Gitlab running on one instance but every now and then we are facing space issues because the large artifacts filled up the space. We have to go and delete the older artifacts folders manually.
Is there a way to automate this? May be a script which runs overnight and delete the artifacts folder older than say 7 days?
The default expiration is set to 5 days in Gitlab Admin but that does not mean they are deleted from the box.
Upvotes: 5
Views: 26814
Reputation: 5659
Turns out, the expiration setting may be ignored by having "Keep artifacts from most recent successful jobs" setting set, and apparently it is enabled by default.
If you go to a pipeline old enough that it should've had its artifacts removed, and see the message These artifacts are the latest. They will not be deleted (even if expired) until newer artifacts are available.
…then likely you stumble upon this problem. To disable that go to your project Settings → CI/CD
, expand Artifacts
, uncheck Keep artifacts from most recent successful jobs
. The URL you can use to access it (substitute the angle-bracket placeholders): https://<domain>/<user_or_group>/<project>/-/settings/ci_cd
Upvotes: 4
Reputation: 41149
When artifacts expire, they should be deleted from disk. If your artifacts are not deleted from your physical storage, there is a configuration issue with your storage. Ensure you have write and delete permissions on your storage configuration.
Artifacts that were created before the default expiration setting was set will still need to be deleted manually -- but one time. All new artifacts will respect the artifact expiration.
However, you should do this through the API, not directly on the filesystem. Otherwise there will be a mismatch between what GitLab's database thinks exists and what actually exists on disk.
For an example script: see this answer.
Also note there are several circumstances under which artifacts are kept, such as the latest artifacts. New pipelines must run for old artifacts to expire. See documentation for more information.
Upvotes: 1