I am trying to setup a global pipeline library that will be explicitly loaded using @Library()
per these instruction. I have this working fine with respect to loading the default library version from master branch.
What I am unable to do is figure out how to configure things so that it can load different branches upon request using the Library('lib-name@branch-name')
syntax.
The instructions say:
"When using Legacy SCM, you will need to include ${library.pipeline-utils.version} in the SCM configuration somewhere."
I have tried using ${library.pipeline-utils.version}
as the value for the Branch Specifier
which is the only logical place I can think to put it. But that just break things. Attempts to load the library fail with:
Fetching upstream changes from ssh://git@stash:7999/jen/pipeline-utils.git
> git --version # timeout=10
> git fetch --tags --progress ssh://git@stash:7999/jen/pipeline-utils.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/${library.pipeline-utils.version}^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/${library.pipeline-utils.version}^{commit} # timeout=10
> git rev-parse origin/${library.pipeline-utils.version}^{commit} # timeout=10
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.
This makes me think I put the variable in the right place but Jenkins is not interpolating it. (Bug?)
This is using Jenkins 2.7.1 and Pipeline version 2.4
This is how I set it, using version variable ${library.CpsGlobal.version}
and Branches to build / Branch Specifier
:
ps. Please remove "-
" character from library name as it's not supported by Groovy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With