What does `resolve` or `library` returning an object let you do?
AdvancedConceptShared libraries
Answer
The library step returns an object through which you can reach src/ classes dynamically without imports:
def lib = library('shack-lib@v1')
def tag = lib.com.devopsshack.ImageTag.forBranch(env.BRANCH_NAME, env.GIT_COMMIT)
This is useful when the library version is chosen at runtime (library "shack-lib@${params.LIB_VERSION}"), since @Library annotations are resolved at compile time and cannot use variables.
More on Shared libraries
What is the directory structure of a shared library?BeginnerHow does a `vars/` global step work?BeginnerWhat goes in `src/` and how is it used?IntermediateHow do classes in `src/` call pipeline steps?IntermediateWhat is `libraryResource` used for?IntermediateWhat are the ways to load a library in a Jenkinsfile?Intermediate