How to store Jenkins Pipeline Global Libraries in RTC
The Jenkins Pipeline functionality allows for retrieving "global libraries" from an SCM and making them available to any of the pipelines defined.
As we use RTC to store our code, I figured I would also try to store global groovy libraries in RTC. When I go to the Jenkins Configure System Page and add a new global library in the "Global Pipeline Libraries" section, I have to select either Modern SCM or Legacy SCM. The RTC plugin does not present an option under Modern so I have to select Legacy.
I'm presented with the standard SCM options for using RTC, load from Build Definition, Repository Workspace, etc...
When using a Legacy SCM, Jenkins pops up this message:
When using Legacy SCM, you will need to include
${library.LIBNAME.version}
in the SCM configuration somewhere.
That is, this variable should be expanded into the specified version and passed to the SCM tool. The only way I could see to use this with RTC was to tell RTC to load a specific workspace and pick a specific Snapshot of that workspace, then I would include the version string in the snapshot name to be loaded.
E.g. if my library version is 1.0.1, my snapshot name is "Jenkins Libraries version 1.0.1", and then I tell the RTC plugin to look for snapshot name "Jenkins Libraries version ${library.LIBNAME.version}".
However, my problem is that when I run my pipeline build on Jenkins, I get this error from the RTC plugin:
FATAL: RTC : checkout failure: A snapshot with name "Jenkins Groovy Libraries ${library.LIBNAME.version}" is not associated with the workspace "BUILD - Jenkins Pipeline Groovy Libraries WS". FATAL: RTC : checkout failure: RTC : checkout failure: A snapshot with name "Jenkins Groovy Libraries ${library.LIBNAME.version}" is not associated with the workspace "BUILD - Jenkins Pipeline Groovy Libraries WS". hudson.AbortException: RTC : checkout failure: A snapshot with name "Jenkins Groovy Libraries ${library.LIBNAME.version}" is not associated with the workspace "BUILD - Jenkins Pipeline Groovy Libraries WS".As you can see, the RTC plugin is using the variable string format, and not an expanded variable string. It's not clear to me why this is not being expanded, except to assume that the RTC plugin never sends these parameters to Jenkins for variable expansion.
So, is there a way to utilize Jenkins Pipeline Global Libraries and the RTC plugin (maybe loading a Workspace Snapshot isn't the best way)? Or maybe this is an error in the Jenkins RTC Plugin.
For now, I am stuck with only one specific version of my libraries and I have to hard-code the snapshot into the Global Jenkins settings (so I cannot use different versions with different Jobs).
I am using the latest Jenkins, Jenkins plugins, and RTC plugin available today: Jenkins 2.89.4 LTS and TeamConcert Plugin 1.2.0.4. My RTC server is at 6.0.4 (I don't control this and cannot make changes to it).
Thanks.
One answer
Hi Nathan
Comments
A snapshot field value like the following