首页 文章

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

提问于
浏览
2

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

http://nexus/service/local/lucene/search?g=com.foo&a=foo-bar&v=

列出快照版本, but also 发行版本,因为工件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任务是不够的,可能是每个工件更新触发的触发器?

1 回答

  • 2

    无需手动解析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对其进行过滤 . 我认为它解决了如何“即使artefactid存在于不同的存储库中也能获得特定Nexus存储库/ artifactid的所有版本” .

相关问题