I’ve done a little plugin I hope might be useful for others who would like to know what is the total size of artefacts stored by Artifactory in local repository.
The functionality is quite simple:
- You can obtain a size of a repository by sending a POST request to url: /artifactory/api/plugins/execute/getRepositorySize?params=repoName=repository-name
- You can obtain a report in a form of a JSON Array for all local repositories by sending a POST request to url: /artifactory/api/plugins/execute/getAllRepositorySizes
Plugin code and a sample JSON response for all repository sizes below.
Just want to add that JFrog did a brilliant work with their very simple and elegant Artifactory API.
To install plugin just copy the RepositorySize.groovy file to ARTIFACTORY_HOME/etc/plugins folder.
I use Groovy a lot. It’s simple and easy to use, runs on JVM and saves me from Java verbosity. I also like the fact that it’s dynamic.
I do convert the maps into JSON when returning results to a browser. I don’t use anything fancy, just a couple lines of Groovy code to do that.
With this code there is quite a bit of assumptions though:
- it will only work for Map
- it assumes Strings are used as Map Keys
- it will convert Maps, Lists and Objects
- when it meets Object it will call .toString() on it to get it’s value
- it will try to format it with tabs and new lines a bit, so it’s more pleasant for the eye and human readable
Hope it would be useful for you. Greg