Created
May 21, 2019 12:29
-
-
Save kumbasar/c7f2217839a4e7a23bf1ad77c73a3287 to your computer and use it in GitHub Desktop.
A bashscript to clean up old builds from Artifactory
This file contains hidden or 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/bash | |
URL="http://localhost:8080" | |
repo="test-repo" | |
TO=`date -d "1 months ago" +%s000` | |
FROM=`date -d "3 months ago" +%s000` | |
curl -u${API_USER}:${API_PASSWORD} -o output.json "${URL}/artifactory/api/search/creation?from=${FROM}&to=${TO}&repos=${repo}" | |
cat output.json | jq '.results[].uri' > artifactlist.json | |
while read line; do | |
echo $line | |
done < "artifactlist.json" | |
# Review artifactlist.json file | |
# mv artifactlist.json deletedartifactlist.json | |
while read line; do | |
curl -u${API_USER}:${API_PASSWORD} -GDELETE $line | |
done < "deletedartifactlist.json" | |
echo "done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment