我想列出 Nexus (2.11.1-01) 快照存储库的所有可用版本。
通过 REST api/lucene 和 gav 坐标
的方式如下:
http://nexus/service/local/lucene/search?g=com.foo&a=foo-bar&v=
列出快照版本,还发布版本,因为工件 foo-bar 也存在于发布存储库中。因此,我阅读了 maven-metadata.xml :
http://nexus/service/local/repositories/com-foo-snapshots/content/com/foo/foo-bar/maven-metadata.xml
lucene 搜索缺乏像 Maven 功能一样的存储库坐标,例如
获取最新版本的快照:
http://nexus/service/local/artifact/maven/resolve?r=com-foo-snapshots&g=com.foo&a=foo-bar&v=0.3-SNAPSHOT
或获取最近的快照版本:
http://nexus/service/local/artifact/maven/resolve?r=com-foo-snapshots&g=com.foo&a=foo-bar&v=LATEST
似乎,我无法使用 maven-metadata.xml,因为并非每个存储库都包含该文件。
即使 artefactid 存在于不同的存储库中,是否有其他方法可以通过 Nexus REST api 或其他 api 获取特定 Nexus 存储库/artifactid 的所有版本?
是否可以强制为每个存储库创建 maven-metadata.xml ?
可用的管理计划 Nexus 任务还不够,也许是每次工件更新时都会触发的触发器?
最佳答案
无需手动解析maven-metadata.xml。
http://nexus/service/local/lucene/search?g=com.foo&a=foo-bar
返回每个 <artifactHit>
唯一标识可以从 Nexus 下载的所有剩余项目,即:<repositoryId>
和<extension>
(和 <classifier>
此处未定义):
...
<artifact>
<groupId>com.foo</groupId>
<artifactId>foo-bar</artifactId>
<version>2.8.1</version>
<latestSnapshot>2.8.5-SNAPSHOT</latestSnapshot>
<latestSnapshotRepositoryId>snapshots</latestSnapshotRepositoryId>
<latestRelease>2.8.3</latestRelease>
<latestReleaseRepositoryId>releases</latestReleaseRepositoryId>
<artifactHits>
<artifactHit>
<repositoryId>releases</repositoryId>
<artifactLinks>
<artifactLink>
<extension>pom</extension>
</artifactLink>
<artifactLink>
<extension>war</extension>
</artifactLink>
</artifactLinks>
</artifactHit>
</artifactHits>
</artifact>
<artifact>
<groupId>com.foo</groupId>
<artifactId>foo-bar</artifactId>
<version>2.8.0</version>
<latestSnapshot>2.8.5-SNAPSHOT</latestSnapshot>
<latestSnapshotRepositoryId>snapshots</latestSnapshotRepositoryId>
<latestRelease>2.8.3</latestRelease>
<latestReleaseRepositoryId>releases</latestReleaseRepositoryId>
<artifactHits>
<artifactHit>
<repositoryId>releases</repositoryId>
<artifactLinks>
<artifactLink>
<extension>pom</extension>
</artifactLink>
<artifactLink>
<extension>war</extension>
</artifactLink>
</artifactLinks>
</artifactHit>
</artifactHits>
</artifact>
因此,在您自己解析lucene/search响应后,您可以通过repositoryId对其进行过滤。我认为它回答了如何“获取特定 Nexus 存储库/artifactid 的所有版本,即使 artefactid 存在于不同的存储库中”。
关于nexus - 通过 REST api 获取 Nexus 存储库的所有版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29165324/