This is regarding @Library vs library and DSL pipelines.
My shared library has a Jenkinsfile that is used to self test the shared library code.
This uses: library ("<lib>@$BRANCH_NAME") _ at line 1 to load the library regardless of the branch in use. Very useful!
My production Jenkinsfiles use @Library("<lib>@<releaseTag>") _
Recently I've added a groovy class to the shared library. The import method doesn't seem to work with library call.
The only way I can get this to work is to use a different Library command
@Library ("<lib>@develop") _
but the dynamic branch no longer works.
Also based on the example from Library doc's
def lib = library('my-shared-library').com.mycorp.pipeline // preselect the package echo useSomeLib(lib.Helper.new(lib.Constants.SOME_TEXT))
WorkflowScript: 1: unable to resolve class MyClass @ line 1, column 11. MyClass c = library("<lib>@$BRANCH_NAME").com.foo.MyClass
This doesn't seem to work. I think this is because this only works with static classes/methods? But the examples don't show the design of the shard library objects in the examples.
Is there a way to get the library() method to work with the import? I prefer the dynamic branch name for the shared library self testing.