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

Fail to call a script method stored as a class attribute/field

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Blocker Blocker
    • workflow-cps-plugin
    • None

      Similar case to 
      https://wiki.jenkins.io/display/JENKINS/Pipeline+CPS+method+mismatches#PipelineCPSmethodmismatches-Directinvocationofclosuresstoredinobjectfieldsormaps

      But instead of Closure, this time the method from loaded script is called, what could be simulated right now even in a single Jenkins file.

      def scriptMethod() {
          println 'passed'
      }
      
      
      class Test {
        def fn
      }
      
      
      node {
          def object = new Test()
          object.fn = this.&scriptMethod
          object.fn.call()
      } 

      Got an exception:

      java.lang.IllegalStateException: expected to call org.codehaus.groovy.runtime.MethodClosure.call but wound up catching WorkflowScript.scriptMethod; see: https://jenkins.io/redirect/pipe
      line-cps-method-mismatches/
      at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService.handleMismatch(CpsVmExecutorService.java:123) at com.cloudbees.groovy.cps.impl.CpsCallableInvocation.checkMismatch(CpsCallableInvocation.java:98)  

      btw, Closure case works fine now. But this is critical as it doesn't allow to break a single Jenkinsfile into a couple of smaller modules (scripts).
       

            Unassigned Unassigned
            dicomj23 Dicom J
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: