Group Repo List via API

Continuing the discussion from Advanced Use Cases for the Nexus Repository Manager API:

Another handy script for listing out the repositories that are members of a repo group.

Group Repo List via API

API Version:

import groovy.json.JsonSlurper
import groovy.json.JsonOutput

//expects json string with appropriate content to be passed in
def repo = null
if (args?.trim()) {
repo = new JsonSlurper().parseText(args)

String groupRepoName = repo?.name

Configuration groupRepoConfig = repository.repositoryManager.get(groupRepoName).getConfiguration();

return JsonOutput.toJson(groupRepoConfig.getAttributes().group.memberNames)

or Scheduled Task Version (the member list will go into your nexus.log):

Configuration groupRepoConfig = repository.repositoryManager.get(“npm-public”).getConfiguration();
(“Group Repo Config: ${groupRepoConfig.getAttributes().group.memberNames}”)