Added script to remove unused artifacts from repository

merge-requests/330/head
Eliot Berriot 2018-07-21 22:28:37 +02:00
rodzic fa673c7c38
commit 870cb69fde
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: DD6965E2476E5C27
1 zmienionych plików z 30 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,30 @@
import gitlab
TOKEN = "CHANGEME"
CLEAN_BEFORE = "2018-07"
gl = gitlab.Gitlab("https://code.eliotberriot.com", private_token=TOKEN, per_page=100)
project = gl.projects.get("funkwhale/funkwhale")
jobs = project.jobs.list(as_list=False)
total = jobs.total
for job in jobs:
if job.attributes["ref"] != "develop":
continue
if job.attributes["status"] != "success":
continue
if job.attributes["tag"] is True:
continue
if job.attributes["name"] not in ["build_api", "build_front", "pages"]:
continue
if job.attributes["created_at"].startswith(CLEAN_BEFORE):
continue
relevant = {
"ref": job.attributes["ref"],
"status": job.attributes["status"],
"tag": job.attributes["tag"],
"name": job.attributes["name"],
"created_at": job.attributes["created_at"],
}
print("Deleting job {}!".format(job.id), relevant)
job.erase()