When I am trying to load a library in the evaluated script, I get "Could not find any definition of libraries [foo]" error. The minimal job is like this:

      evaluate '@Library("foo") _'
      

      It would be really nice if this code worked as-is, but any workaround would help me too.

          [JENKINS-40560] Allow loading libraries in evaluated scripts

          Jesse Glick added a comment -

          Why would you want to do this? And even if you did, I think JENKINS-39450 would be a better approach.

          Jesse Glick added a comment - Why would you want to do this? And even if you did, I think JENKINS-39450 would be a better approach.

          Roman Timushev added a comment - - edited

          We use evaluate to load jenkinsfiles with non-default names in multibranch pipelines. A separate step to load a library will help, although it means that @Library annotation becomes completely useless for us.

          Roman Timushev added a comment - - edited We use evaluate to load jenkinsfiles with non-default names in multibranch pipelines. A separate step to load a library will help, although it means that @Library annotation becomes completely useless for us.

          Sam Liddicott added a comment -

          I really wish that at least built parameters or env vars could be expanded in the @Library string.

          Sam Liddicott added a comment - I really wish that at least built parameters or env vars could be expanded in the @Library string.

          Jesse Glick added a comment -

          samliddicott you can use the library step for dynamic import of libraries.

          Jesse Glick added a comment - samliddicott you can use the library step for dynamic import of libraries.

            Unassigned Unassigned
            rtimush Roman Timushev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: