nexus - 通过 REST api 获取 Nexus 存储库的所有版本

标签 nexus

我想列出 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/

相关文章:

ant - Ivy:检索在 Nexus 及其依赖项中发布的快照

maven - Nexus 在复杂的 Maven 项目上暂存 Maven 插件?

node.js - 如何在 yarn 中指定本地注册表?

java - mvn 包忽略 pom.xml 中的存储库

maven - 插件 'maven-dependency-plugin:2.8' 的错误解析版本

bash - 使用 find 和 curl 将目录内容上传到 Sonatype Nexus 存储库

java - Maven - 查看依赖树而不构建项目

maven - 使用功能分支时避免 Maven 存储库版本冲突

curl - 使用 curl : 500 Server Error 将工件包上传到 sonatype

maven - IntelliJ 使用带有时间戳的快照而不是 -SNAPSHOT 来构建 Artifact