工件版本号的 Sonatype Nexus 端点

Sonatype Nexus endpoint for artifact's version number

Nexus 中是否有获取工件最新版本的端点 number(pom 的版本)?

如果工件在 Nexus 中的最新版本是 0.0.8-SNAPSHOT,端点将 return0.0.8-SNAPSHOT。

您可以使用以下 Nexus resolve REST API 获取 XML 文档,其中包含有关 POM 的详细信息,包括版本:

http://nexus/service/local/artifact/maven/resolve?g=groupId&a=artifactId&v=LATEST&r=snapshots&p=pom

然后您需要解析 baseVersion 元素中的文本,例如

<artifact-resolution>
  <data>
    ...
    <groupId>groupId</groupId>
    <artifactId>artifactId</artifactId>
    <version>1.0-20160000.100000-1</version>
    <baseVersion>1.0-SNAPSHOT</baseVersion>
    <extension>pom</extension>
    <snapshot>true</snapshot>
    ...
  </data>
</artifact-resolution>

参考:

https://repository.sonatype.org/nexus-restlet1x-plugin/default/docs/path__artifact_maven_resolve.html