Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the Nexus3 API how do I get a list of artifacts in a repository

Tags:

nexus

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.

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]

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")

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.

Is there a way to do this via the Nexus 3 API?

like image 476
Graeme Neath Avatar asked Dec 09 '16 14:12

Graeme Neath


1 Answers

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

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.

like image 182
DarthHater Avatar answered Jan 03 '23 22:01

DarthHater