samrocketman/nexus3-config-as-code

Restoring Nexus Repo and Blob Configuration

sanakhanlibre opened this issue · 2 comments

Hi,

I have been trying to restore nexus configuration following the guide and I get the following error.

I am not familiar with groovy, just trying out the backup and restore using the scripts provided in this repo.

$ ./scripts/upload_function.py -rf ./functions/repositoryConfiguration.groovy -d repository.json
HTTP ERROR 400: Bad Request
https://<repo-url>/service/rest/v1/script/repositoryConfiguration/run
{
  "name" : "repositoryConfiguration",
  "result" : "org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:\nScript8.groovy: 233: You cannot create an instance from the abstract interface 'org.sonatype.nexus.repository.config.Configuration'.\n @ line 233, column 23.\n           repo_config = new Configuration()\n                         ^\n\nScript8.groovy: 345: You cannot create an instance from the abstract interface 'org.sonatype.nexus.selector.SelectorConfiguration'.\n @ line 345, column 20.\n           selector = new SelectorConfiguration(name: name, type: 'csel')\n                      ^\n\n2 errors\n"
}

Please find attached my repositories.json

Is my repositories.json incorrectly configured?

Any help would be appreciated.

Thanks & Regards,
Sana

I haven’t updated this repository since sonatype deprecated use of Groovy scripts.

Creating the scripts from scratch involved dozens possibly hundreds of hours of source review of nexus-public. Because of this time spent and the deprecated feature I don’t want to waste time updating scripts for a feature that could go away.

The error seems clear to me on line 233 Configuration class has turned into an interface so you need to find the class that replaces it. I recommend going through the history of nexus-public and walking the history of that class to find when it became an interface.

For now, I don’t have plans to update this code but pull requests are welcome.

As an aside, I walked the history just now with my ipad and the new class name appears to be

org.sonatype.nexus.repository.config.internal.orient.OrientConfiguration

When this change was introduced 5 years ago. Looking at the latest main branch this class still exists but I don’t advise it without a deeper review.