gitlab占用空间很大时,清除 GitLab 上所有 CI/CD 的 artifact

gitlab占用空间很大时,如何清理

gitlab 启用cicd时候未设置过期时间,导致工程cicd记过占用过大清理方式

#!/bin/bash
# set -x
# project_id, find it here: https://gitlab.com/[organization name]/[repository name]/edit inside the "General project settings" tab
project_id="17159201"

# token, find it here: https://gitlab.com/profile/personal_access_tokens
token="MU3vhyu54MTdR8oj5gfj"
server="gitlab.transai.net"
start_job=1
end_job=18390

# job_ids=(1 18390)
# 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 "
"
# done
for (( job_id = $start_job; job_id <= $end_job; job_id++ )) do
echo "$job_id"

echo Job ID being deleted is "$job_id"

curl --request POST --header "PRIVATE-TOKEN:${token}" "https://${server}/api/v4/projects/${project_id}/jobs/${job_id}/erase"
echo -en 'n'
echo -en 'n'
done

https://kheresy.wordpress.com/2021/03/19/remove-all-artifact-of-gitlab-ci-cd/

https://www.arsano.ninja/2019/05/09/automate-gitlab-artifact-deletion/

https://gist.github.com/carceneaux/b75d483e3e0cb798ae60c424300d5a0b

https://gitlab.com/-/snippets/1979158

https://forum.gitlab.com/t/remove-all-artifact-no-expire-options/9274/2

原文地址:https://www.cnblogs.com/ronaldHU/p/15217245.html