简体   繁体   中英

AQL or REST API Artifactory to remove empty folders

I have to remove empty folders from Artifactory. The preferred way to do that was changing rules in AQL, but as far as I know, it's not possible to do it without removing non-empty Artifactory folders. I tried to add type rules as follow:

"type": {"$eq":"any"}

Also, I cannot add plugins to Artifactory API, so I can't use Empty Folder Clean-up
Finally, I was trying to use curl with REST API Artifactory to list all folders with paths and pull these that haven't any subfolders, something like:

curl -u "${username}":"$password" -X GET "<url>/artifactory/api/storage/<repo>/jenkins/artifacts?list&deep=1&listFolders=1" | jq '.file
s[].uri' | awk -F '"' '{ print $2 }' | awk -F '/' '{ print $2 }' | sort | uniq -c

And remove folders that don't have subfolders (children). But I'm not sure that it's the best idea. Do you have some suggestions on how Could I do it better and more effectively? Or maybe some other ideas?
Thank you in advance for any help!

There is this User Plugin to delete the empty directories that you can use to remove the empty folders.

You can use the rm-empty JFrog CLI Plugin to remove empty folders from a specific path in Artifactory. The plugin is registered on the JFrog CLI Plugins Registry .

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM