I need to write a shell script, that can get outdated artifacts from JFROG by using REST API and delete them.
I get a list of artifacts by command
curl -u user:password "http://artifactory:8081/artifactory/api/search/dates?dateFields=created&from=1467052559000&to=1497588559000&repos=current-repo"
and get an output like
"results" : [ {
"uri" : "http://artifactory:8081/artifactory/api/storage/current-repo/first artifact/artfoulder folder/file.tzs",
"created" : "2017-04-10T11:33:50.190+03:00"
}, {
"uri" : "http://artifactory:8081/artifactory/api/storage/current-repo/second artifact/artfoulder folder/file2.tzs",
"created" : "2017-04-10T11:33:50.140+03:00"
} ]
and other artifacts
After I successfully got the list of these artifacts, I need to delete them.
My questions:
Thanks a lot in advance!
Why not using a script is already ready specifically for that: https://github.com/JFrogDev/artifactory-scripts/blob/master/cleanup/aqlCleanup.groovy
All you will need to do is change the AQL query to search artifacts on specific date range and that is it. This will automatically clean up.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.