Reputation: 7709
I have a global library configured in Jenkins. It works. But when my Pipeline is stored in SCM, it tells me that it cannot find it when I tried to load it. A workaround is to load it implicitly.
But how can I access the classes in the library then? I can not do
@Library("mylib") import ...
Because that triggers the error.
Upvotes: 1
Views: 946
Reputation: 792
I'm getting used to this myself at the moment.
I initially read https://jenkins.io/doc/book/pipeline/shared-libraries/#loading-libraries-dynamically to mean that unless you're in a Jenkinsfile, you need to use the syntax:
library 'mylib'
However, I have since realised that actually you can use Library
but need to include an underscore or a specific import, i.e.
@Library('mylib') _
See https://issues.jenkins-ci.org/browse/JENKINS-42807?attachmentViewMode=list for where I discovered that.
Does that help at all?
Upvotes: 2