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

Metaprogramming with InvokerHelper and MethodMissing triggers CPS MisMatch log

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • workflow-cps-plugin
    • None
    • workflow-cps:2.7.1
    • workflow-cps 2.73

      I currently work on a plugin ([Templating Engine Plugin|https://plugins.jenkins.io/templating-engine]) that relies on being able to leverage metaprogramming techniques such as using snippets like:

      InvokerHelper.getMetaClass(impl).invokeMethod(impl, methodName, args)
      

      or methodMissing to control program flow. 

       

      The introduction of logging CPS mismatched method names has resulted in continuously logging these occurrences. 

       

      Is there a way to work around the CPS mismatch logs for instances such as leveraging methodMissing or the InvokerHelper to dynamically execute methods? 

       

      methodMissing log:

      expected to call org.boozallen.plugins.jte.binding.injectors.StepWrapper.doThing but wound up catching org.boozallen.plugins.jte.binding.injectors.StepWrapper.methodMissing; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/
      expected to call org.boozallen.plugins.jte.hooks.Hooks.invoke but wound up catching script15632181891161818312862.call; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/

      InvokerHelper log:

      expected to call groovy.lang.ExpandoMetaClass.invokeMethod but wound up catching script1563218188258613791966.doThing; see: https://jenkins.io/redirect/pipeline-cps-method-mismatches/
      

       

      Simplest example to reproduce: 

       

      import org.codehaus.groovy.runtime.InvokerHelper
      c = {
          println "doing a thing"
      }
      InvokerHelper.getMetaClass(c).invokeMethod(c, "call", null)
      

       

            sterrana Steven Terrana
            sterrana Steven Terrana
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: