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

          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 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

          @Library does not work in combination with SCRIPT_SPLITTING_TRANSFORMATION=true, so I was hoping that this function would work. But it is not.

          Torsten Kleiber added a comment - @Library does not work in combination with SCRIPT_SPLITTING_TRANSFORMATION=true, so I was hoping that this function would work. But it is not.

          Override does not work too for "Pipeline Libraries" configured in folders from multibranch pipelines.

          Torsten Kleiber added a comment - Override does not work too for "Pipeline Libraries" configured in folders from multibranch pipelines.

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

              Created:
              Updated: