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

          Roman Timushev created issue -
          Roman Timushev made changes -
          Description Original: 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:

          {code:groovy}
          evaluate '@Library("foo") _'
          {code}

          It would be really nice if this code worked as-is, but any workaround would help me too.
          New: 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:

          {code}
          evaluate '@Library("foo") _'
          {code}

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

          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.
          Jesse Glick made changes -
          Link New: This issue relates to JENKINS-39450 [ JENKINS-39450 ]
          Jesse Glick made changes -
          Resolution New: Won't Do [ 10001 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

          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 made changes -
          Assignee New: Sam Liddicott [ samliddicott ]
          Sam Liddicott made changes -
          Assignee Original: Sam Liddicott [ samliddicott ]

          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: