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

Cannot use function calls in shared library step

XMLWordPrintable

      When trying to implement a declarative pipeline inside of a shared library step, I'm finding that this only works if the pipeline is defined inside the "call" method.  As soon as I add a function call, I start seeing exceptions.

       

      Working code:

      def call() {
        pipeline {
          agent any
      
          stages {
            stage("Stage") {
              steps {
                echo "hi"
              }
            }
          }
        }
      } 

       

      Non-working code:

      def call() {
        execute()
      }
      
      def execute() {
        pipeline {
          agent any
      
          stages {
            stage("Stage") {
              steps {
                echo "hi"
              }
            }
          }
        }
      } 

       

      Error message:

      hudson.remoting.ProxyException: groovy.lang.MissingPropertyException: No such property: any for class

       

      For reasons beyond this post, we are trying to add some commonality and argument checking to our steps, which is why I'd like to be able to use that concept of the extra function call...

       

            Unassigned Unassigned
            w60001 Christopher Shannon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: