8

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?

Graeme Neath
  • 83
  • 1
  • 1
  • 5
  • Possible duplicate of [Download all Nexus 3 Artifacts](https://stackoverflow.com/questions/46467106/download-all-nexus-3-artifacts) – 030 Apr 25 '19 at 15:59

2 Answers2

5

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.

DarthHater
  • 3,222
  • 25
  • 26
  • Thx - I used this as a basis to write some repo evaluation and component deletion scripts... https://github.com/danischroeter/nexus-repo-scripting – Daniel Schröter Oct 05 '17 at 12:01
1

Once your migration is done, it can be worth to investigate to update your version of Nexus.

That way, you will be able to use the - still in beta - new API for Nexus. It's available by default on the version 3.3.0 and more: http://localhost:8082/swagger-ui/

Basically, you retrieve the json output from this URL: http://localhost:8082/service/siesta/rest/beta/assets?repositoryId=YOURREPO

Only 10 records will be displayed at a time and you will have to use the continuationToken provided to request the next 10 records for your repository by calling: http://localhost:8082/service/siesta/rest/beta/assets?continuationToken=46525652a978be9a87aa345bdb627d12&repositoryId=YOURREPO

More information here: http://blog.sonatype.com/nexus-repository-new-beta-rest-api-for-content

Djidiouf
  • 786
  • 1
  • 10
  • 23