Hi, 

I put that (tested) one-liner for converting a xml to a Map to a @NonCPS 
funkction

@NonCPS
def readXml( String xml ) {
   return new XmlSlurper().parseText(xml).children().collectEntries { n-> [(
n.name()):{->n.children()?.collectEntries(owner)?:n.text()}()]}
}



When using it inside a pipeline script like:

node {
    stage('Checkout configuration') {
      ...
    
      String xml = readFile("path/to/myfile.xml" )
      def root = readXml ( xml )
}



it´s telling me:


hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No 
signature of method: groovy.util.slurpersupport.NodeChildren.collectEntries() 
is applicable for argument types: (WorkflowScript$_readXml_closure1) values: 
[WorkflowScript$_readXml_closure1@35ff77c8]
        at 
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:55)
        at 
org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:51)
        at 
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
        at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
        at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
        at WorkflowScript.readXml(WorkflowScript:9)


Any ideas? The readXml(...) function is working when used outside of 
Jenkins workflow-cps-plugin

Best regards, Torsten


-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/cfa05c43-f610-4d92-af61-80eac8a71853%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to