At work, we have been using Nexus OSS 1.8.0 for a few years now. Recently, I (as a Nexus admin) have been asked how many artifacts are in our instance. It’s a very simple question, but I can’t for the life of me find an answer anywhere:
- I couldn’t find it in Nexus’ UI, Google or here;
- Looking at Nexus’ REST API, there is a search endpoint (two, actually, although data_index is now deprecated), which also returns how many results the query yielded (field totalCount), except that I haven’t figured out how to just search for everything: providing an empty parameter yields a 400 response.
I provided a reasonable estimate of many artifacts we have, and that’s good enough for now, but I had more work than I felt I should’ve had… Did anybody have the same problem?
Update:
I needed to know how many internal artifacts we have (as opposed to external dependencies from Maven Central and the like), so I ended up GET-ing:
http://<OUR-NEXUS>/service/local/lucene/search?q=*&repositoryId=<OUR-REPO>
for every hosted repository and adding up the totalCount fields.
For the full count, searching for q=* yielded too many results, so I ran:
find $PATH_TO_SONATYPE_HOME | grep sha1 | egrep -v 'nexus-maven-repository-index|repository-metadata|maven-metadata|\.pom\.sha1' | wc -l
But I’m still surprised this type of information isn’t readily available…
What Mark suggested is ok, but if you count sha1 files instead, you’ll get a more accurate count as nexus will create that file on upload of every artifact.