【问题标题】:Using the Nexus3 API how do I get a list of artifacts in a repository使用 Nexus3 API 如何获取存储库中的工件列表
【发布时间】:2017-04-25 02:10:59
【问题描述】:

我们正在从 Nexus Repository Manager 2.1.4 迁移到 Nexus 3.1.0-04。在版本 2 中,我们已经能够使用 API 按存储库获取工件列表,但是我们正在努力寻找使用 Nexus 3 API 的方法。

阅读 https://books.sonatype.com/nexus-book/reference3/scripting.html 第 16 章后,我们已经能够使用以下 groovy 脚本获取特定 blob 的工件信息:

import org.sonatype.nexus.blobstore.api.BlobId

def properties = blobStore.blobStoreManager.get("default").get(new BlobId("7f6379d32f8dd78f98b5b181166703b6")).getProperties()
return [headers: properties.headers, metrics: properties.metrics]

但是,我们找不到迭代 blob 存储内容的方法。我们可以得到一个 blob 存储对象:

blobStore.blobStoreManager.get("default")

但是,API 似乎没有为我们提供获取该商店中所有 blob 列表的方法。我们需要获取 blob 存储中的 blobID 列表。

有没有办法通过 Nexus 3 API 做到这一点?

【问题讨论】:

标签: nexus


【解决方案1】:

迁移完成后,值得调查以更新您的 Nexus 版本。

这样,您将能够使用 - 仍处于测试阶段 - Nexus 的新 API。它在 3.3.0 及更高版本上默认可用:http://localhost:8082/swagger-ui/

基本上,您从以下 URL 检索 json 输出:http://localhost:8082/service/siesta/rest/beta/assets?repositoryId=YOURREPO

一次只会显示 10 条记录,您必须使用提供的 continuationToken 来为您的存储库请求接下来的 10 条记录,方法是调用:http://localhost:8082/service/siesta/rest/beta/assets?continuationToken=46525652a978be9a87aa345bdb627d12&repositoryId=YOURREPO

更多信息在这里:http://blog.sonatype.com/nexus-repository-new-beta-rest-api-for-content

【讨论】:

    【解决方案2】:

    我们的一位内部团队成员将这些放在一起。它不使用 blobStore 但完成了我相信您正在尝试做的事情(还有更多):https://gist.github.com/kellyrob99/2d1483828c5de0e41732327ded3ab224

    对于一些背景知识,将 blobStore 视为我们存储位的位置,没有关于它们的信息。 OrientDB 具有组件/资产记录并存储有关它们的所有信息。结果,您通常希望使用它而不是 blobStore 来获取资产信息。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-05
    • 2012-09-13
    • 2020-07-19
    • 2017-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多