Reputation: 141
We are running Nexus:3.29.2 and I want to add a groovy script to a Admin-Execute task. To start I am attempting to execute the following sample script:
import org.sonatype.nexus.repository.Repository
repository.repositoryManager.browse().each { Repository currentRepository ->
// do some stuff in each repository
log.info("Found repository: " + currentRepository)
}
But the task fails and the log shows: unable to resolve class org.sonatype.nexus.repository.Repository
Where is the groovy script supposed to import from?
Upvotes: 1
Views: 1006
Reputation: 66
When the Groovy script runs inside Nexus (it is implied from your question), it has access to all Nexus JARs, so no explicit import should be required.
The org.sonatype.nexus.repository.Repository
interface is located in nexus-repository-config-<VERSION>.jar
. E.g. for Nexus OSS 3.36.0 the exact location would be $NEXUS_HOME/system/org/sonatype/nexus/nexus-repository-config/3.36.0-01/nexus-repository-config-3.36.0-01.jar
.
When the Groovy script runs outside Nexus, just put all necessary JARs into ~/.groovy/lib
, as described here
Upvotes: 3