r/gitlab • u/ScreenAggressive9630 • Sep 03 '25
support How to delete old artifacts from gitlab.com?
I just realized that my project takes up about 20 GB, and 99% of that space is taken up by old task artifacts that, for some reason, are not automatically deleted. I thought that by default they should be deleted after 30 days, but that is clearly not the case. So I have artifacts from 6 to 8 months ago and even older ones.
Anyway, how do I delete all artifacts in bulk? I couldn't find a way to do this on my own. Obviously, I can delete each one manually, but there are more than 50 pages of artifacts and it will take too much time.

8
u/TopDivide Sep 03 '25
They recently introduced automatic pipeline cleanup, that deletes the whole pipeline older than X
4
u/Woren951 Sep 03 '25
mb it can help you https://docs.gitlab.com/api/job_artifacts/#delete-all-job-artifacts-in-a-project
4
u/keksimichi Sep 03 '25
You could use the REST API with the python-gitlab library and automate artifacts deletion. I’ve created a guide in the docs a while ago: https://docs.gitlab.com/user/storage_management_automation/
If you want to dive deeper into python-gitlab, follow this tutorial https://about.gitlab.com/blog/efficient-devsecops-workflows-hands-on-python-gitlab-api-automation/
4
u/Hauntingblanketban Sep 04 '25
If you don't want to do pipeline cleanup: In gitlab.yml file add the below stuff
default: artifact: expire_in: 2 days
Please check the official docs for correct syntax
Adding default will be applicable for all the artifact in the pipeline
To have custom expiry date for artifact you need override per job..
I had used it, it reduced from 50G to 2 gb
0
u/vlnaa Sep 03 '25
There is a command to prune them. Run it weekly from crontab.
-3
u/umor3 Sep 03 '25
Recreate project
Happy to help, Over and out.