After I deleted the real archive "Artifacts.zip" on the Server, but gitlab web still shows "Build Artifacts: 46.5 GB"

After I deleted the real archive “Artifacts.zip” on the Server, but gitlab web still shows “Build Artifacts: 46.5 GB”

/var/opt/gitlab/gitlab-rails/shared/artifacts/ [project HASH path] /Artifacts.zip

GitLab will still have a record of the artifacts, you can use the API to remove the artifact record. This StackOverflow page can also be useful in your research.

Thank you so much, I have solved this problem!

Because our job has more than 200 pages, and the job ID will skip numbers, so the numbers will not be consecutive.

Is there a way to export all the job IDs contained in the project ID at one time?

You can use the List Project Jobs endpoint, and query the result as needed.

1 Like

I’m not sure if I understand it wrong.
It seems that you can only query jobs according to the pipeline.

But what I need is all the job IDs in the whole project to delete the space occupied by Artifacts.

How can i do it?

And another [List project jobs] query will be divided into more than 300 pages by pages, I can’t find out the job ID for each page.

Or, how can I directly connect to gitlab’s DB & filter out the job ID of a specific project?

Hi @suparu :wave: If your goal is to remove all the artifacts, does this API work for you: Job Artifacts API | GitLab?

It was introduced in 14.7 and generally available since 14.10 and it lets you clear all the artifacts of a project :slightly_smiling_face:

Beware, of course, that you’ll loose all of them :sweat_smile:

No, my main goal is to clear the space occupied by the job’s Artifacts.

However, although I have physically cleared the zip archive now, the GB counted by the project is wrong, which is the size before deleting the Artifacts.

So what should I do?

If you removed the actual zip file then you basically won’t ever be able to download it again, right? Then, if you already deleted the artifacts files, why not remove all the artifacts with the API I linked? :thinking:

That API would:

  1. remove the arifacts files
  2. remove the artifacts from the database

From what I understood, step :one: was already done by you manually, so you’re just missing step :two:, right?

From what I understood, step :one: was already done by you manually, so you’re just missing step :two:, right?

  1. yes~~~But I directly enter the linux system to find the zip file of a specific project and delete the zips. Do I need to delete it again through the API?

I have seen [Delete project artifacts] & [Delete job artifacts] which one should I use?

If my project ID=16, what does the API I should execute look like?

2.If I finish 1., will the gitlab project display the correct project size? Or as [abubakar] said, do I need to delete all job in in project?

Thanks for your kindly response.

Do I need to delete it again through the API?

Yes, because, from what I understood, the informations about artifacts are also stored inside the database so to actually see the artifacts size decrease you’ll need to update that and you should do it by using the APIs, not touching the DB directly :slightly_smiling_face:

I have seen [Delete project artifacts] & [Delete job artifacts] which one should I use?

They are basically the same, the difference is that “Delete project artifacts” will remove the artifacts from all the project’s jobs, while “Delete job artifacts” lets you delete artifacts on a per-job way :slightly_smiling_face: “Delete project artifacts” was introduced to prevent users from having to iterate through all the jobs (your use case basically) :slightly_smiling_face:

If my project ID=16, what does the API I should execute look like?

The API call would look something like this:

curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/16/artifacts"

If I finish 1., will the gitlab project display the correct project size? Or as [abubakar] said, do I need to delete all job in in project?

I think @abubakar is right, you’ll have to not only remove the artifacts zip files but also update the database. Informations about the artifacts are stored inside the database to speedup things like, for example, knowing the size of the artifacts :slightly_smiling_face: So yeah, use the APIs to both remove the zip files and clear the database informations :slightly_smiling_face:

I don’t want to seem pedantic but I want to make this clear once more: this operation is destructive, if you use that API you won’t be able to access the artifacts ever again (unless you restore the database and the zip files, if you have a backup) :slightly_smiling_face:

Thanks a lot.

I consulted the RD team and thought it was necessary to keep the current job.
However, in a job-by-job method, the number of executions that need to be performed is too large.

We decided to wait for the project to come to an end and then perform the entire erase operation.

Glad to hear you found a way to solve this :slightly_smiling_face: