用于从 Nexus OSS 3.x 存储库获取工件列表的 Rest API

Roh*_*ith 7 rest nexus sonatype

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

Pie*_*tto 6

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

卷曲-X GET“ http://localhost:8081/service/rest/v1/components?repository=central ”-H“接受:application/json”

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

结果是一个 JSON 字符串。

相反,如果您想执行组件搜索 - 基于 groupId、artifactId - 您可以使用以下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“接受:应用程序/json”

这将返回带有子资产的组件。

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


Dji*_*ouf 3

您可以使用 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