Interview Prep/Jenkins/Shared libraries

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.

All Jenkins questions Roadmap: Jenkins

More on Shared libraries