Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-54655

declarative library fails to override implicitly loaded library

      If the declarative syntax is used for loading a shared library it fails to override the impliciliy loaded global library.  The "Allow default version to be overridden" configuration is set.

      This is a drawback from the old @LIBRARY(...) syntax.

      pipeline {
          libraries {
              lib('TF_CD_LIB@master')
          }
      ...
      }
      

      Pipeline:

       

      Only using first definition of library TF_CD_LIB
      

       

          [JENKINS-54655] declarative library fails to override implicitly loaded library

          Michael Werner created issue -
          Michael Werner made changes -
          Assignee New: Andrew Bayer [ abayer ]
          Andrew Bayer made changes -
          Assignee Original: Andrew Bayer [ abayer ]

          Ankur added a comment -

          Any update on this ? Facing same issue. Have a shared lib defined in global configuration with 'Load implicitly' and 'Allow default version to be overridden' checked but declarative pipeline is not able to override the default version. No errors, but it always load the default version.

          Ankur added a comment - Any update on this ? Facing same issue. Have a shared lib defined in global configuration with 'Load implicitly' and 'Allow default version to be overridden' checked but declarative pipeline is not able to override the default version. No errors, but it always load the default version.

          ankurja you can overwrite it with 
           @Library('my-shared-library@my-special-branch') _
           

          Michael Werner added a comment - ankurja  you can overwrite it with   @Library('my-shared-library@my-special-branch') _  
          Ankur made changes -
          Comment [ [~xaseron] I am using declarative pipeline which does not seem to support @Library syntax. I am trying to use "library 'my-shared-library@my-special-branch'" but it makes no effect. It still loads the version defined in global settings. ]

          Ankur added a comment -

          Thanks xaseron . I am able to override with the syntax you mentioned.

          Ankur added a comment - Thanks xaseron . I am able to override with the syntax you mentioned.

          ankurja yes it works. Just put at top of your Jenkinsfile before the pipeline block.

          Michael Werner added a comment - ankurja  yes it works. Just put at top of your Jenkinsfile before the pipeline block.

          John Pfuntner added a comment -

          xaseron's suggestion also worked for me but I would like to parameterize the branch rather than hardcode it.  Can that be without the parameters section?  It's kind of like the chicken and the egg.

          John Pfuntner added a comment - xaseron 's suggestion also worked for me but I would like to parameterize the branch rather than hardcode it.  Can that be without the parameters section?  It's kind of like the chicken and the egg .

          Bas van Driel added a comment -

          +1 i would also like to use the library() syntax because of dynamically loading the current working branch of the libs

          Bas van Driel added a comment - +1 i would also like to use the library() syntax because of dynamically loading the current working branch of the libs

            Unassigned Unassigned
            xaseron Michael Werner
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: