Remove Gitlab-CI artifacts in batch using the API

Currently Gitlab does not support artifact removal if you forgot to set an expires_in parameter.

I was not a huge fan of the current solutions so I made my own. Instead of looping through every job ids that might be yours we extract the job ids through the browser JavaScript console and use them inside our script below :


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

# token, find it here: https://gitlab.com/profile/personal_access_tokens

# 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[@]};
 echo "$URL"
 curl --request POST --header "PRIVATE-TOKEN:${token}" "$URL"
 echo "\n"
« »
Made with on a hot august night from an airplane the 19th of March 2017.