【问题标题】:Rest API to get list of artifacts from Nexus OSS 3.x RepositoryRest API 从 Nexus OSS 3.x 存储库获取工件列表
【发布时间】:2017-10-06 04:45:00
【问题描述】:

我在 Nexus 3.x 中创建了一个原始存储库,并且可以将工件上传到该存储库。现在我想使用 Rest API 获取驻留在该仓库中的所有工件的列表。 任何帮助表示赞赏。

【问题讨论】:

标签: rest nexus sonatype


【解决方案1】:

在当前的 Nexus3.14.0-04 中,REST API 已成为最终版本(不再是“测试版”),您需要的 curl 是:

curl -X GET "http://localhost:8081/service/rest/v1/components?repository=central" -H "accept: application/json"

这将返回每个“组件”(组、名称、版本)及其所有资产 = 构成该组件的每个单独文件(pom、sha1、md5、jar)

结果是一个 JSON 字符串。

如果您想要执行 COMPONENTS 搜索 - 基于 groupId、artifactId - 您可以使用此 curl:

curl -X GET "http://localhost:8081/service/rest/v1/search?repository=central&format=maven2&maven.groupId=com.fasterxml.jackson.core&maven.artifactId=jackson-core&maven.extension=jar" -H "accept: application/json"

这将返回带有子资产的 COMPONENTS。

仅检索资产而不按组件分组的变体是 GET /service/rest/v1/search/assets?repository=central&format=maven2&maven.groupId=com.fasterxml.jackson.core&maven.artifactId=jackson- core&maven.extension=jar

【讨论】:

  • 我已经尝试过这种方法,并且我有包含许多组件的 repo,并且 json 响应似乎被分块并且不返回完整列表。有人遇到过这个问题,有解决方法吗?
【解决方案2】:

您可以使用 - 仍处于测试阶段 - 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

【讨论】:

    猜你喜欢
    • 2016-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-21
    • 1970-01-01
    • 2015-05-23
    相关资源
    最近更新 更多