I'm having some difficulty with global shared groovy libraries in pipelines 
(Jenkins 2.242, with Pipeline:Groovy Shared Libraries 2.16) and could use a 
swift kick in the proper direction.

I've configured a local bare git repository using it's path in the System 
Configuration, which correctly reports the commit associated with the HEAD 
of master. Since this is local, there are no credentials involved.

The groovy script is loaded in my pipeline (not a Jenkinsfile, just a 
simple project), as follows - from a file outside the workspace, which is 
not yet populated at the load step:

        stage('load') {
            steps {
                script {
                    modules.first = load 
pwd()+'/../../OtherJob/workspace/publisher.groovy'
                }
            }
        }

The load works and I can execute simple things, but when trying to 
reference the library I get the error that
ERROR: Could not find any definition of libraries [mylib],

The first line of the publisher.groovy script is:
@Library('mylib') _

And the exception thrown is below (there is more, obviously). Nothing in 
the jenkins log, this is from the build console

org.jenkinsci.plugins.workflow.cps.CpsCompilationErrorsException: startup 
failed:
Script1.groovy: Loading libraries failed

1 error

        at 
org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
        at 
org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1085)
        at 
org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
        at 
org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
        at 
org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
        at 
groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
        at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
        at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
        at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
        ...

I really want to share code (not variables) as I have about 30 pipelines 
that need my groovy classes. Obviously I'm doing something wrong, but the 
diagnostics are not providing a nice hint to help me out with resolving 
this. Any suggestions?

Thanks in advance,
Randall


-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/f5350044-b8b1-4e3e-b613-36bb9eade86ao%40googlegroups.com.

Reply via email to