【问题标题】:Get all versions of a Nexus repository via REST api通过 REST api 获取 Nexus 存储库的所有版本
【发布时间】:2015-05-23 18:59:20
【问题描述】:

我想列出 Nexus (2.11.1-01) 快照存储库的所有可用版本。 通过 REST api / lucene 和 gav coordinates 的方式就像这样:

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 功能 f.e. 那样的存储库坐标
获取最新版本的快照:

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,因为不是每个存储库都包含该文件。
是否有任何其他方式通过 Nexus REST api 或其他 api 来获取特定 Nexus 存储库/artifactid 的所有版本,即使 artefactid 存在于不同的存储库中?
是否可以强制为每个存储库创建 maven-metadata.xml?
可用的管理计划 Nexus 任务还不够,可能是每次工件更新都会触发的触发器?

【问题讨论】:

    标签: nexus


    【解决方案1】:

    无需手动解析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 存在于不同的存储库中”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-06-03
      • 2012-06-06
      • 2013-01-24
      • 2017-10-06
      • 1970-01-01
      • 2022-08-16
      • 1970-01-01
      相关资源
      最近更新 更多