I need to read data from 2 xml files. I have the following pipeline script:
            def targetServerConfigFileContent = readFile file: 'apiproxy/targets/default.xml'               
            def xmlObject1 = new XmlSlurper().parseText(targetServerConfigFileContent);
            echo "-------------"
            existingTargetServerName = xmlObject1.HTTPTargetConnection.LoadBalancer.Server.'@name';
            echo "existingTargetServerName::${existingTargetServerName}"
            targetServerConfigFileContent = null;
            xmlObject1 = null;
            def proxyConfigFileContent = readFile file: 'apiproxy/'+ proxyName + '.xml'
            def xmlObject = new XmlSlurper().parseText(proxyConfigFileContent);
            existingProxyName = xmlObject.'@name'
            existingBasePath = xmlObject.Basepaths              
            existingProxyDesc = xmlObject.Description
            echo "existingProxyName::${existingProxyName}"
            echo "existingProxyDesc::${existingProxyDesc}"
            echo "existingBasePath::${existingBasePath}"
            proxyConfigFileContent = null;
            xmlObject = null;
The moment, I start reading the second file with code, it started throwing the exception.
def proxyConfigFileContent = readFile file: 'apiproxy/'+ proxyName + '.xml'
Exception:
java.lang.IllegalArgumentException: Could not instantiate {message=java.io.NotSerializableException: groovy.util.slurpersupport.Attributes} for EchoStep(message: String): java.lang.ClassCastException: org.jenkinsci.plugins.workflow.steps.EchoStep.message expects class java.lang.String but received class java.io.NotSerializableException
Please let me know what was the wrong with the code.
 
    