Created
March 15, 2022 15:01
-
-
Save sssemil/43f7994218762a29617540376927fe48 to your computer and use it in GitHub Desktop.
This script helps you with removal of all artifacts in a project.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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