Skip to content
Snippets Groups Projects
Verified Commit afa85791 authored by Kristian Klausen's avatar Kristian Klausen :tada:
Browse files

Use job token instead of project access token for deleting old packages

The project access token expired ~3 months ago and apparently the job
token has the scopes needed for deleting old packages, so let's just use
that instead of creating a new project access token. I assume it was not
possible to delete packages with the job token, when this was initially
implemented[1].

[1] d04c8274 ("Use GitLab's package registry for releases instead of tags")
parent c77872be
No related branches found
No related tags found
No related merge requests found
Pipeline #110245 failed
......@@ -207,5 +207,5 @@ cleanup:
script:
- |
for id in $(curl --silent --fail --show-error "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages?per_page=100&order_by=created_at&sort=asc" | jq '.[] | select(.created_at | split("T")[0] | . < (now-60*60*24*90|strflocaltime("%Y-%m-%d"))) | .id'); do
curl --silent --fail --show-error --request DELETE --header "PRIVATE-TOKEN: ${GITLAB_PROJECT_TOKEN}" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/${id}"
curl --silent --fail --show-error --request DELETE --header "JOB-TOKEN: ${CI_JOB_TOKEN}" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/${id}"
done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment