Manually remove artifacts from CI

I have a private repository on gitlab.com that uses the CI function. Some of the CI jobs create artifact files that are stored. I just realized that artifacts are automatically deleted after one day, adding this to the CI configuration:

expire_in: 1 day

This works fine, however old artifacts will not be deleted (as expected). So my question is:

How to remove old artifacts or artifacts that do not expire? (on gitlab.com, without direct access to the server)

+10
source share
4 answers

GitLab REST API , . curl, API:

#!/bin/bash

# project_id, find it here: https://gitlab.com/[organization name]/[repository name]/edit inside the "General project settings" tab
project_id="3034900"

# token, find it here: https://gitlab.com/profile/personal_access_tokens
token="Lifg_azxDyRp8eyNFRfg"
server="gitlab.com"

# go to https://gitlab.com/[organization name]/[repository name]/-/jobs
# then open JavaScript console
# copy/paste => copy(_.uniq($('.ci-status').map((x, e) => /([0-9]+)/.exec(e.href)).toArray()).join(' '))
# press enter, and then copy the result here :
# repeat for every page you want
job_ids=(48875658 48874137 48873496 48872419)

for job_id in ${job_ids[@]};
do
 URL="https://$server/api/v4/projects/$project_id/jobs/$job_id/erase"
 echo "$URL"
 curl --request POST --header "PRIVATE-TOKEN:${token}" "$URL"
 echo "\n"
done
+7

GItlab 8.17 , , :

/var/opt/gitlab/gitlab-rails/shared/artifacts/<year_month>/<project_id?>/<jobid>

, GitLab

, : https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/administration/job_artifacts.md#storing-job-artifacts

+5

, ( ) .

+1

@-

After I ran into a similar problem, I basically converted @ david-archer's answer to a web application. https://github.com/Harmannz/gitlab-artifact-remover

They may be useful to you or other people who come across this post.

0
source

Source: https://habr.com/ru/post/1015339/


All Articles