我试图使用JsonSlurper从不同的文件输入变量 . 但它在第二次执行时失败了 . 有人能帮帮我吗?
它从步骤 Jenkins_File_Path = readFile ( "${Local_Path_App}" + "/Jenkinsfile" ) 失败了
Main.groovy
import groovy.json.JsonSlurper
Global_Settings_Path = readFile ("${Main_Local_Path}" + "/Config/GlobalSettings_Java.json" )
def jsonSlurper = new JsonSlurper()
def GlobalVariables = jsonSlurper.parseText(Global_Settings_Path)
Jenkins_File_Path = readFile ( "${Local_Path_App}" + "/Jenkinsfile" )
def jsonSlurper1 = new JsonSlurper()
def json = jsonSlurper1.parseText(Jenkins_File_Path)
GlobalSettings_Java.json
{
"LOB": {
"SVN_Config_Path": "testpath",
"Local_Path_LOB": "test",
}
}
Jenkinsfile
{
"BUILD_INFO": {
"Build_Type" : "Maven",
}
}
Error Logs
java.io.NotSerializableException:groovy.json.internal.LazyMap在org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)在org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java: 65)在org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)在org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)在org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride (RiverObjectOutputStream.java:179)在java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)在java.util.HashMap.internalWriteEntries(HashMap.java:1785)在java.util.HashMap.writeObject(HashMap.java: 1362)在sun.reflect.GeneratedMethodAccessor469.invoke(未知来源)在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)在java.lang.reflect.Method.invoke(Method.java:498)在org.jboss .marshalling.reflect.SerializableClass.callWriteObject( SerializableClass.java:271)在org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:976)在org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)在org.jboss.marshalling .river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)在org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)在org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854 )在org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)在org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)在org.jboss.marshalling.river.RiverMarshaller . doWriteSerializableObject(RiverMarshaller.java:967)在org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)在org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)在org.jboss .marshalling.river.RiverMarshaller.doWr iteSerializableObject(RiverMarshaller.java:988)在org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)在org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)在org.jboss .marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)在org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)在org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java :854)在org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)在org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)在org.jboss.marshalling.MarshallerObjectOutputStream . writeObjectOverride(MarshallerObjectOutputStream.java:50)在org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)在java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)在java.util.TreeMap.writeObje CT(TreeMap.java:2438)在sun.reflect.GeneratedMethodAccessor475.invoke(未知来源)在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)在java.lang.reflect.Method.invoke(Method.java: 498)在org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:271)在org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:976)在org.jboss.marshalling.river.RiverMarshaller .doWriteObject(RiverMarshaller.java:854)在org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)在org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)在有机jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)在org.jboss.marshalling.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:58)在org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:111)在org.jenkinsci.plugins.workflow.support.pi ckles.serialization.RiverWriter.writeObject(RiverWriter.java:132)在org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:433)在org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram( CpsThreadGroup.java:412)在org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:357)在org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access $ 100(CpsThreadGroup.java:78)在org.jenkinsci.plugins.workflow.cps.CpsThreadGroup $ 2.call(CpsThreadGroup.java:236)位于org.jenkinsci.plugins的org.jenkinsci.plugins.workflow.cps.CpsThreadGroup $ 2.call(CpsThreadGroup.java:224) . workflow.cps.CpsVmExecutorService $ 2.call(CpsVmExecutorService.java:63)atjava.util.concurrent.FutureTask.run(FutureTask.java:266)位于java的jenkins.util.ContextResettingExecutorService $ 1.run(ContextResettingExecutorService.java:28)的hudson.remoting.SingleLaneExecutorService $ 1.run(SingleLaneExecutorService.java:112) .util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511)at java.util.concurrent.FutureTask.run(FutureTask.java:266)at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) )java.util.concurrent.ThreadPoolExecutor $ java.lang.Thread.run(Thread.java:745)中的java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)由以下原因引起的异常:在字段调用者中的字段本地对象中的字段程序中的字段e对象org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@7abaf96e中的字段线程完成:FAILURE