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

Unable to use global function defined within library project

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Critical Critical
    • None
    • workflow-cps-global-lib-plugin 2.4
      jenkins 2.21

      Defining a shared library with this structure:

       +- src
       |   +- org
       |       +- foo
       |           +- Bar.groovy  # for org.foo.Bar class
       +- vars
       |   +- execEcho.groovy
      

      Where Bar.groovy is:

      class Bar {
          def steps
      
          Bar(steps) { this.steps = steps)
      
          def doEcho(message) { steps.execEcho message }
      }
      

      and execEcho.groovy is

      def call(message) {
        echo message
      }
      

      Using this code within a pipeline

      ...
      def bar = new Bar(steps)
      bar.doEcho("Hello World!")
      ...
      

      Fails with:

      java.lang.NoSuchMethodError: No such DSL method 'execEcho' found among steps [...] or symbols [..., execEcho, ...]
      

      Even though execEcho shows up as one of the symbols

            Unassigned Unassigned
            patresi Ricardo Reis
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: