It seems that is not possible to load a shared library from a CRs gerrit branch, mostly because current GitSCMSource plugin fails to see gerrit branches, and tuning the rawRefSpecs parameter seems to have no effect on it.
library identifier: 'temp-lib@master', retriever: modernSCM(
rawRefSpecs: '+refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/remotes/origin/tags/* +refs/changes/*:refs/remotes/changes/*'
Example of using git ls-remote on gerrit repository:
git ls-remote https:558aca4bf8d2eb357caa72292abb94b3b87cc41f HEAD
As you can see, ls-remote is able to detect gerrit branches without problems. Still, I we check the console log of the job, we will find that Jenkins is trying to perform a "git ls-remote -t -h ..." which is filtering out the remote branches that we are interested about.
I was not able to find any option to tell it not to do this.