Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nexus: How many artifacts do we have?

Tags:

nexus

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...

like image 957
Humberto Anjos Avatar asked Jan 26 '26 15:01

Humberto Anjos


1 Answers

Try the following:

find $PATH_TO_SONATYPE_HOME -name "*.jar" | wc -l

It will only count JAR artfacts but that normally accounts for the bulk of files stored in Nexus

like image 170
Mark O'Connor Avatar answered Jan 29 '26 13:01

Mark O'Connor