@@ -290,68 +290,7 @@ In the course of time the size of data generated for gitlab-ci pipelines may gro
- use [cache](https://docs.gitlab.com/ee/ci/yaml/#cache) instead of artifacts when possible when jobs with dependencies can be executed on the same machine,
- generate fewer archives and lighter archives, keeping only what is strictly necessary.
To view and delete artifacts and logs there is for example this tool [gitlab-storage-analyzer](https://gitlab.com/gitlab-de/use-cases/gitlab-api/gitlab-storage-analyzer). This tool use the Gitlab's REST API to execute tasks on the project, thus you must get:
- a [Personal Access Token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html) with **api** access,
- the gitlab's project **id**, see the number in front of Project ID on the main page of your project.
Then you can clone it locally, install python-gitlab with pip
To only look for archives and exclude logs (called trace here) use `GL_EXCLUDE_FILE_TYPE`
```sh
export GL_EXCLUDE_FILE_TYPE="trace,metadata"
```
To only look for logs
```sh
export GL_EXCLUDE_FILE_TYPE="archive,metadata"
```
To only look for artifacts older than a number of seconds use `GL_THRESHOLD_AGE_SEC`
```sh
export GL_THRESHOLD_AGE_SEC=604800 # i.e. older than 1 week
```
Then to actually delete the filtered artifacts use `GL_DELETE_MODE`
```sh
export GL_DELETE_MODE=threshold # none by default
```
Unfortunately this script cannot be used to delete logs (only archives) associated with pipelines and which, yet, can be responsible for a large amount of the storage quota.
To remove logs of a pipeline there is no other way than deleting the pipeline. The script [cleanup-gitlab-pipelines.sh](https://gitlab.inria.fr/siteadmin/doc/-/snippets/897"cleanup-gitlab-pipelines") allows to delete 100 (max pagination size) pipelines older than a certain date:
```sh
export GL_SERVER=https://gitlab.inria.fr
export GL_TOKEN=
export GL_PROJECT_ID=
export GL_DELETE_BEFORE="2023-01-01"
./cleanup-gitlab-pipelines.sh
```
To delete more than 100 pipelines one has to repeat this operation several times.
After having doing that the storage quota can be recalculated on the page Settings -\> Usage Quotas, button "Recalculate repository usage" and wait several minutes to get a refreshed page up-to-date (the result is not instantaneous).