I have a Jenkins shared library set up like:
shared-library
└── vars
├── testA.groovy
└── testB.groovy
All the documentation I can find on shared libraries mentions that you can use an underscore in @Library('shared-library') _ to import everything in vars, but I can't find anything about how to only import a subset of vars.
I strongly dislike import * or other types of imports that bring in everything from an external source because it makes the source of the imports unclear and harms maintainability. Therefore I like to enforce a coding standard that imports must be explicit.
However, none of the documentation explains how to import specific functions from vars.
I can do something like @Library("jenkins-build-lib") import testA, but this still seems to import everything from vars. For example, if I do the following:
@Library("jenkins-build-lib") import testA
node ('myNode') {
testA()
testB()
} //node
I would expect this job to fail due to not recognizing testB, however there is no error generated and testB even executes successfully.
Is there a way to import only a selected subset of functions from vars in a given pipeline?