Skip to content

Instantly share code, notes, and snippets.

@sssemil
Created March 15, 2022 15:01
Show Gist options
  • Save sssemil/43f7994218762a29617540376927fe48 to your computer and use it in GitHub Desktop.
Save sssemil/43f7994218762a29617540376927fe48 to your computer and use it in GitHub Desktop.
This script helps you with removal of all artifacts in a project.
#!/bin/sh
#<your project id (you can find it with inspect element on the project page)>
PROJECT_ID=36944
#<your access token (can be generated in your profile settings)>
ACCESS_TOKEN=xxxxx-XXXXXXXXXXXXXXXXXXXX
#<your gitlab instance hostname (ex. gitlab.lrz.de)>
GL_SERVER=gitlab.lrz.de
for PAGE in $(seq 1 1000); do
echo "Currently on page ${PAGE}"
JOBS=$(curl --globoff --header "PRIVATE-TOKEN: ${ACCESS_TOKEN}" "https://${GL_SERVER}/api/v4/projects/${PROJECT_ID}/jobs?per_page=10&page=${PAGE}")
JSON_EXT=$(echo $JOBS | jq 'map(.id)')
echo $JSON_EXT
echo $JSON_EXT | jq -c '.[]' | while read job_id; do
curl --request POST --header "PRIVATE-TOKEN:${ACCESS_TOKEN}" "https://${GL_SERVER}/api/v4/projects/${PROJECT_ID}/jobs/${job_id}/erase"
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment