It's all about the answers!

Ask a question

How to store Jenkins Pipeline Global Libraries in RTC


Nathan Hellwig (1122) | asked Mar 15 '18, 4:54 p.m.

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



permanent link
Lakshmi Narasimhan T V (4415) | answered Mar 16 '18, 6:18 a.m.
JAZZ DEVELOPER

Hi Nathan


If you are using snapshot (associated with a workspace), then the snapshot names should be version numbers like 1.0, 2.0 etc., In the snapshot field of RTC SCM configuration, you have to put ${library.<yourlibraryname>.version}, where <your library name> is the name of the GSL.  This will expand to the version number that is specified as default. If you use the @Library annotation with a version number at the end, then the property will expand to that specific version number. A snapshot whose name matches  that version number should exist in the repository workspace.




Comments
Lakshmi Narasimhan T V commented Mar 16 '18, 6:42 a.m. | edited Mar 16 '18, 6:42 a.m.
JAZZ DEVELOPER

A snapshot field value like the following

Jenkins Groovy Libraries - ${library.<yourlibraryname>.version} should resolve to Jenkins Groovy Libraries - 1.0. Currently Team Concert Plugin cannot resolve a property inside a string in the snapshot field, it only deferences if the field just has a property reference and nothing else. I have created a work item 454942 in jazz.net to fix this. 

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.