Nexus Public API with Groovy - Unable to resolve class

706 views
Skip to first unread message

michal....@globallogic.com

unread,
Aug 16, 2018, 9:29:36 AM8/16/18
to Nexus Users
Hello,

When I pull sonatype/nexus3 image is it possible to use jars from it to add them to CLASSPATH and run groovy script for creating repository?
My question comes from situation when I received below error after running groovy script in Docker container:

/usr/bin/build-classpath: Could not find ../../jvm/java/lib Java extension 
for this JVM /usr/bin/build-classpath: error: Some specified jars were not found
org.codehaus.groovy.control.MultipleCompilationErrorsException: startupfailed:
/usr/bin/scripts/list.groovy: 1: unable to resolve class org.sonatype.nexus.repository.Repository
@ line 1, column 1.
import org.sonatype.nexus.repository.Repository
^

It is my code:

import org.sonatype.nexus.repository.Repository

repository.repositoryManager.browse().each { Repository repo ->
    println repo.name
}

Is it good way to do it?

Thanks for help :)

Rich Seddon

unread,
Aug 16, 2018, 9:38:07 AM8/16/18
to Nexus Users
No, that won't work.  You need to run scripts via REST API or scheduled task:


BTW, I strongly recommend setting up an IDE so you can browse into our source code:


That makes writing scripts much easier.

And be sure to close transactions!

Message has been deleted

michal....@globallogic.com

unread,
Aug 17, 2018, 4:55:00 AM8/17/18
to Nexus Users
Rich, thank you so much :)  It is working!
Have a nice day!
Reply all
Reply to author
Forward
0 new messages