Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nexus REST API query artifacts within a group

Tags:

rest

nexus

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.

like image 746
Sergei Ledvanov Avatar asked Jul 25 '14 13:07

Sergei Ledvanov


1 Answers

It came out that everything I needed is to fetch ˇmaven-metadata.xml` file that comprises all versions available for this artifact. For example,

https://oss.sonatype.org/service/local/repositories/snapshots/content/com/alibaba/rocketmq/rocketmq-all/maven-metadata.xml

contains

<?xml version="1.0" encoding="UTF-8"?>
<metadata modelVersion="1.1.0">
  <groupId>com.alibaba.rocketmq</groupId>
  <artifactId>rocketmq-all</artifactId>
  <versioning>
    <latest>3.1.8-SNAPSHOT</latest>
    <release></release>
    <versions>
      <version>3.0.2-open-SNAPSHOT</version>
      <version>3.0.10-ALIYUN-SNAPSHOT</version>
      <version>3.0.11-SNAPSHOT</version>
      <version>3.1.8-SNAPSHOT</version>
    </versions>
    <lastUpdated>20140807060304</lastUpdated>
  </versioning>
</metadata>
like image 62
Sergei Ledvanov Avatar answered Jan 01 '23 20:01

Sergei Ledvanov