I have a Nexus maven repo and I would like to leverage REST API to query the list of artifacts lying in my specific group. I stumbled upon this documentation but it seems to be very concise and I cannot find there what I need.
https://oss.sonatype.org/nexus-restlet1x-plugin/default/docs/rest.html
I want something like this
http://mydomain:8081/nexus/service/local/repositories/list?groupId=com.test.superproduct&repo=snapshots
And it would output me a list
- product-1.0.0-SNAPSHOT
- product-1.0.1-SNAPSHOT
- product-1.0.2-SNAPSHOT .....
To be more specific I need a list of versions of artifacts lying in a group, but I can extract versions from artifact names too.
It came out that everything I needed is to fetch ˇmaven-metadata.xml` file that comprises all versions available for this artifact. For example,
contains
No need to manually parse maven-metadata.xml. No need to manually parse directory names or file names.
returns not only every
<version>
, but as a bonus, for every artifact of this version, all the identifiers needed to obtain an unique download URL for any single file residing on this Nexus instance. The identifiers required for download URL are:<groupId>
,<artifactId>
(both of which you say you already know),<version>
,<repositoryId>
,<extension>
(and<classifier>
which is optional and undefined in my example):After you parse
lucene/search
response, a good idea would be to filter it by repositoryId being eitherreleases
orsnapshots
.This answer is for Nexus 2.11.
Usually you would want to use the lucene index maintained for the repositories for lookups like this. See the REST documentation for the indexer plugin, you can search for groupId and artifactId here.