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:
- Is there a simple way to do it? Or I need to parse output strings with shell, put links in array and delete by REST API command one by one?
- It there a way to get only first-level artifact folders, that are outdated and delete them (first artifact and second artifact in my case)
Thanks a lot in advance!