Skip to content

Instantly share code, notes, and snippets.

@kumbasar
Created May 21, 2019 12:29
Show Gist options
  • Save kumbasar/c7f2217839a4e7a23bf1ad77c73a3287 to your computer and use it in GitHub Desktop.
Save kumbasar/c7f2217839a4e7a23bf1ad77c73a3287 to your computer and use it in GitHub Desktop.
A bashscript to clean up old builds from Artifactory
#!/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