Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to put ${library.pipeline-utils.version} when using Git SCM to setup Global Pipeline Library

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

like image 379
Kenneth Baltrinic Avatar asked Jan 06 '23 04:01

Kenneth Baltrinic


1 Answers

This is how I set it, using version variable ${library.CpsGlobal.version} and Branches to build / Branch Specifier :

enter image description here

ps. Please remove "-" character from library name as it's not supported by Groovy.

like image 122
luka5z Avatar answered Jan 14 '23 13:01

luka5z