Skip to content
doronshai edited this page May 30, 2018 · 4 revisions

Delete list of images from registry

for i in $( curl -uadmin:aaaaaaaaaaa -X GET "https://artifactory.info:443/artifactory/api/docker/docker/v2/aaaaaa/tags/list" | perl -p -e 's/\", \"/\n/g' |grep headdetachedat | sed  "s/\"tags\"\ \:\ //" | sed "s/\[//" | sed "s/\]//"  | sed "s/\"//" | sed "s/\ //" | sort  -r ); do
curl -uadmin:aaaaaaaaaaa -X DELETE "http://artifactory.info:8081/artifactory/docker-local/aaaaaa/$i"
done

Delete Images, keep 20 latest

for i in $( curl -uadmin:aaaaaaaaaaa -X GET "https://artifactory.info:443/artifactory/api/docker/docker/v2/aaaaaa/tags/list" | perl -p -e 's/\", \"/\n/g' |grep dev | sed  "s/\"tags\"\ \:\ //" | sed "s/\[//" | sed "s/\]//"  | sed "s/\"//" | sed "s/\ //" | awk -F'-' '{print $0|"sort -t',' -nk2 "}' | sort -r | tail +20 ); do
curl -uadmin:aaaaaaaaaaa -X DELETE "http://artifactory.info:8081/artifactory/docker-local/aaaaaa/$i"
done

Go over all branches, all Images and keep latest 5

#!/bin/bash
for branch in "dev" "master"; do
  for service in "jtracker" "commonbudget" "adintegration" "flumeboradcast" "flumebudget" "flumeclick"; do
    for i in $( curl -s -uadmin:APBbenBScaUySh3s8q1whjLRTEK -X GET     "https://artifactory.nyj.taptica.info:443/artifactory/api/docker/docker/v2/$service/tags/list" | perl -p -e 's/\", \"/\n/g' |grep $branch | sed  "s/\"tags\"\ \:\ //" | sed "s/\[//" | sed "s/\]//"  | sed "s/\"//" | sed "s/\ //" | awk -F'-' '{print $0|"sort -t',' -nk2 "}' | sort -r | sed -e '1,5d' ); do
        echo "================="
        echo service - $service
        echo tag - $i
        curl -uadmin:APBbenBScaUySh3s8q1whjLRTEK -X DELETE "http://artifactory.nyj.taptica.info:8081/artifactory/docker-local/$service/$i"
    done
  done
done