0

I’ve been able to create, using the Nexus groovy scripts, more specifically associating a Routing Rule to and existing repository.

It’s pretty easy to create one; such code evaluated fine from Groovy: RoutingRule routingRule = new RoutingRule("com.company only API", "only com.company content", RoutingMode.BLOCK, ["^(?!/com/company)/.*\$"])

The part I could not figure out was how to persist this rule and attach it to an existing repository. I tried with: Configuration.setRoutingRuleId(EntityHelper.id(ruleName)) without success.

Anyone know-how is the correct configuration to associate a proxy repository to a routing rule?

Nexus OSS version: 3.19.1-01

Edit: I solved my problem by updating my version of Nexus to OSS 3.21.1-01 and start using the API that now they have RoutingRules methods.

1 Answers1

0

Not sure if you've found an answer here given it's already 2 months old. I was also having this problem and took me long to figure this out so for anyone looking:

def rule = routingRuleStore.getByName('RULENAME')
config.routingRuleId = org.sonatype.nexus.common.entity.EntityHelper.id(rule)

Then you can save/update with

repositoryManager.create(config)
repositoryManager.update(config)
dyeprii
  • 36
  • 2
  • Thanks, @dyeprii your answer works, but actually I solved my problem updating my version of Nexus to OSS 3.21.1-01 and start using the API that now they have RoutingRules methods. – Pablo Rodriguez May 12 '20 at 10:15