I am working on Jfrog Artifactory - Groovy script to delete the complete folder with artifacts. I have a respository with folder 2015.08.18.1.SNAPSHOT and it has child items 2015.08.18.1.12345.pom, 2015.08.18.1.12345.war, matadata.xml. With the below script i am able to delete only the child items (2015.08.18.1.12345.pom, 2015.08.18.1.12345.war, matadata.xml) and not the folder(2015.08.18.1.SNAPSHOT) , my requirement is to delete folder also.
def delete(RESTClient restClient, List itemsToDelete, def dryRun) {
dryMessage = (dryRun) ? "*** This is a dry run ***" : "";
itemsToDelete.each {
println("Trying to delete artifact: '$it'. $dryMessage")
try {
if (!dryRun) {
restClient.delete(path: it)
}
println("Artifact '$it' has been successfully deleted. $dryMessage")
} catch (HttpResponseException e) {
println("Cannot delete artifact '$it': $e.message" + ", $e.statusCode")
} catch (HttpHostConnectException e) {
println("Cannot delete artifact '$it': $e.message")
}
}
}
Here, 'itemsToDelete' holds '2015.08.18.1.SNAPSHOT'