Nexus Rest API. List() repository

2,778 views
Skip to first unread message

Saatvik Ramisetty

unread,
Jul 27, 2016, 3:04:49 PM7/27/16
to Nexus Users
Hi,

I was looking to use a list method to list out all the artifacts in a nexus 3 repository, eventually, I am looking to retrieve the version number of the artifacts.

Is there a method in the API to do that?

Saatvik

Harpreet Nain

unread,
Sep 30, 2016, 4:01:56 PM9/30/16
to Nexus Users, vishnu....@gmail.com
I am also trying to find that. Did you get an answer to your query?

Jeffry Hesse

unread,
Sep 30, 2016, 4:04:45 PM9/30/16
to Harpreet Nain, Nexus Users, vishnu....@gmail.com
Hi there,

At current time we do not have a REST API in Nexus Repository Manager 3. You could however likely accomplish this using the Integrations API: http://books.sonatype.com/nexus-book/reference3/scripting.html, you could write a script to return the list and send it back as JSON, etc...

Jeffry

--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users...@glists.sonatype.com.
To post to this group, send email to nexus...@glists.sonatype.com.
To view this discussion on the web visit https://groups.google.com/a/glists.sonatype.com/d/msgid/nexus-users/35a112b6-b60e-4821-96f9-e5320e7314f0%40glists.sonatype.com.
For more options, visit https://groups.google.com/a/glists.sonatype.com/d/optout.

Harpreet Nain

unread,
Sep 30, 2016, 4:50:55 PM9/30/16
to Nexus Users, harpre...@gmail.com, vishnu....@gmail.com
can you please share an example. I have seen the scripting examples, couldn't find one that queries the server.

Regards
Harpreet

Jeffry Hesse

unread,
Sep 30, 2016, 5:00:10 PM9/30/16
to Harpreet Nain, Nexus Users, vishnu....@gmail.com
Right now the scripting examples are fairly limited, I'm working on expanding those as we get more from awesome people like you (so if you get this working, please do share!)

To accomplish what you want to do, you'll need to use something akin to RepositoryManager, which is from nexus-repository

Location:
components/nexus-repository/src/main/java/org/sonatype/nexus/repository/manager/RepositoryManager.java

I would imagine you can use browse() to get a list. 

Of note, these are internal methods/classes, not a public API, so they can be likely to change in the future.


Deven Phillips

unread,
Oct 24, 2016, 3:49:24 PM10/24/16
to Nexus Users, harpre...@gmail.com, vishnu....@gmail.com
Jeffry,

    I've been digging into this and it's not really possible without some better documentation or some assistance from someone at Sonatype... To get an instance of RepositoryManager(Impl) requires injecting a number of constructor arguments from a number of different places. As yet, I have not been able to determine where those objects would come from or how to get them bootstrapped into a DSL script.

  @Inject
  public RepositoryManagerImpl(final EventBus eventBus,
                               final ConfigurationStore store,
                               final RepositoryFactory factory,
                               final Provider<ConfigurationFacet> configFacet,
                               final Map<String, Recipe> recipes,
                               final RepositoryAdminSecurityConfigurationResource securityResource,
                               final List<DefaultRepositoriesContributor> defaultRepositoriesContributors)
  {
    this.eventBus = checkNotNull(eventBus);
    this.store = checkNotNull(store);
    this.factory = checkNotNull(factory);
    this.configFacet = checkNotNull(configFacet);
    this.recipes = checkNotNull(recipes);
    this.securityResource = checkNotNull(securityResource);
    this.defaultRepositoriesContributors = checkNotNull(defaultRepositoriesContributors);
  }

Any assistance would be greatly appreciated.

Deven Phillips

Deven Phillips

unread,
Oct 24, 2016, 4:03:58 PM10/24/16
to Nexus Users, harpre...@gmail.com, vishnu....@gmail.com
Oh Wait!!! Crap! I had me Maven config wrong for being able to script... Looks like I can have this knocked out shortly!!!

Deven

Jeffry Hesse

unread,
Oct 24, 2016, 4:05:28 PM10/24/16
to Deven Phillips, Nexus Users, harpre...@gmail.com, vishnu....@gmail.com
Haha, awesome. Let us know Deven! Also, please share your script with me once you get it working, I'm going through and trying to add community scripts to an area where others can learn from your hard work :)

--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users...@glists.sonatype.com.
To post to this group, send email to nexus...@glists.sonatype.com.

Deven Phillips

unread,
Oct 26, 2016, 9:30:37 AM10/26/16
to Jeffry Hesse, Nexus Users, harpre...@gmail.com, vishnu....@gmail.com
I made some progress, but I am still running into a wall due to lack of documentation...

I know that I can get a reference to the repository:

def repo = repository.repositoryManager.get('maven-releases')

I know that I will need to get some Facet on that repository in order to get a list of items in that repository

def f = repo.facet(SomeFacet)

But after looking through everything I can find so far, none of the Facet implementations appear to have what I need. I have looked at:

SearchFacet
ViewFacet
MavenHostedFacet
MavenIndexFacet
MavenHostedIndexFacet
StorageFacet

None of them appear to expose an API which would let me get a list/iterator of artifacts. The only thing I can think of is that the SearchFacet allows you to dispatch() a Request and receive a Response, but I have no idea of the format/parameters of what such a request would look like.

Any help would be appreciated!

Deven

On Mon, Oct 24, 2016 at 4:05 PM, Jeffry Hesse <jhe...@sonatype.com> wrote:
Haha, awesome. Let us know Deven! Also, please share your script with me once you get it working, I'm going through and trying to add community scripts to an area where others can learn from your hard work :)
On Mon, Oct 24, 2016 at 11:49 AM Deven Phillips <deven.p...@gmail.com> wrote:
Jeffry,

    I've been digging into this and it's not really possible without some better documentation or some assistance from someone at Sonatype... To get an instance of RepositoryManager(Impl) requires injecting a number of constructor arguments from a number of different places. As yet, I have not been able to determine where those objects would come from or how to get them bootstrapped into a DSL script.

  @Inject
  public RepositoryManagerImpl(final EventBus eventBus,
                               final ConfigurationStore store,
                               final RepositoryFactory factory,
                               final Provider<ConfigurationFacet> configFacet,
                               final Map<String, Recipe> recipes,
                               final RepositoryAdminSecurityConfigurationResource securityResource,
                               final List<DefaultRepositoriesContributor> defaultRepositoriesContributors)
  {
    this.eventBus = checkNotNull(eventBus);
    this.store = checkNotNull(store);
    this.factory = checkNotNull(factory);
    this.configFacet = checkNotNull(configFacet);
    this.recipes = checkNotNull(recipes);
    this.securityResource = checkNotNull(securityResource);
    this.defaultRepositoriesContributors = checkNotNull(defaultRepositoriesContributors);
  }

Any assistance would be greatly appreciated.

Deven Phillips

--
You received this message because you are subscribed to the Google Groups "Nexus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users+unsubscribe@glists.sonatype.com.

Abhaya Ghatkar

unread,
Feb 20, 2017, 2:01:15 AM2/20/17
to Nexus Users, jhe...@sonatype.com, harpre...@gmail.com, vishnu....@gmail.com
Hi ,

Even I'm trying to implement same, did you get this script working?
To unsubscribe from this group and stop receiving emails from it, send an email to nexus-users...@glists.sonatype.com.
Reply all
Reply to author
Forward
0 new messages