使用Nexus3 API如何获取存储库中的工件列表 [英] Using the Nexus3 API how do I get a list of artifacts in a repository
问题描述
我们正在从Nexus Repository Manager 2.1.4迁移到Nexus 3.1.0-04.在第2版中,我们已经能够使用API来按存储库获取工件列表,但是我们正在努力寻找一种使用Nexus 3 API来实现此目的的方法.
We are migrating from Nexus Repository Manager 2.1.4 to Nexus 3.1.0-04. With version 2 we have been able to use the API to get a list of artifacts by repository, however we are struggling to find a way to do this with the Nexus 3 API.
已阅读 https://books.sonatype.com/nexus-book/reference3/scripting.html 第16章,我们已经能够使用诸如
Having read https://books.sonatype.com/nexus-book/reference3/scripting.html chapter 16 we have been able to get artifact information for a specific blob using a groovy script like:
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存储对象:
However we can't find a way to iterate over the contents of a blob store. We can get a blob store object:
blobStore.blobStoreManager.get("default")
但是,API似乎并未给我们提供一种获取该商店内所有blob列表的方法.我们需要获取Blob存储中的BlobID列表.
however the API does not appear to give us a way to get a list of all blobs within that store. We need to get a list of the blobIDs within a blob store.
是否可以通过Nexus 3 API做到这一点?
Is there a way to do this via the Nexus 3 API?
推荐答案
我们的内部团队成员之一对此进行了汇总.它不使用blobStore,但是可以完成我相信您正在尝试做的事情(还有更多): https ://gist.github.com/kellyrob99/2d1483828c5de0e41732327ded3ab224
One of our internal team members put this together. It doesn't use the blobStore but accomplishes I believe what you are trying to do (and a bit more): https://gist.github.com/kellyrob99/2d1483828c5de0e41732327ded3ab224
对于某些背景,可以将blobStore视为我们存储位的位置,而没有关于它们的信息. OrientDB具有组件/资产记录并存储有关它们的所有信息.因此,通常需要使用它而不是blobStore来获取资产信息.
For some background, think of a blobStore as just where we store the bits, with no information about them. OrientDB has Component/Asset records and stores all the info about them. You'll generally want to use that instead of the blobStore for Asset information as a result.
这篇关于使用Nexus3 API如何获取存储库中的工件列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!