'Jenkins Transitive Dependency between Global Pipeline Libraries
My setup includes 2 Jenkins pipeline libraries, e.g. lib_generic
and lib_specialized
, where the second one depends on the first one (will call classes and global vars from the first one).
I have to write my Jenkinsfile
with the @library
header that includes both:
@Library(['lib_generic', 'lib_specialized']) _
or
@Library(['lib_generic@v1', 'lib_specialized@v2']) _
In other words, the Jenkinsfile has to declare the transitive dependencies of the pipeline libraries it uses. I would like to hide that implementation detail.
Ideally, I would like my second library itself to specify its dependency on the library lib_generic
, and then have the Jenkinsfile
only declare the library lib_specialized
.
@Library(['lib_specialized@v2']) _
Is there a known way to do this?
I would like to add a couple comments:
- I realize that what I'm asking for, forces me to choose the version of the first library explicitly in the second one, OR delegate to the Global settings, so I probably won't be able to overwrite anything in the
Jenkinsfile
. I am okay with that (it's an implementation detail!). - I could use "Load implicitly" for the first library when defining it in the Global Settings. But again, seems like an implementation detail.
- The dynamic library loading feature should be possible, but this seems impractical to me as I would need to declare and import the library over and over in all Classes and global var for the second library. Unless there is a better way?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|