接收原因:java.io.NotSerializableException:groovy.util.slurpersupport.Attributes错误

时间:2019-05-18 18:55:47

标签: xml jenkins groovy

我知道对于詹金斯来说,它要求所有变量都需要序列化,但是我遇到了一个问题,我不明白为什么。我对Groovy / Jenkins还是很陌生。这是我的代码


@NonCPS
String myFunction(){
def parsed = new XmlSlurper().parse("${workspace}/tmp/TESTS-myTest.xml")
println "${parsed} is this"
//def errorMessage = parsed.testsuite.testcase.error.@message
//def testCases = parsed.testsuite.testcase

    println "We found 0 errors"

    parsed.testsuite.testcase.each { def device ->
    msgToSlack= "Name of phone is: ${device.@name}" + " " + "ran for ${((device.@time.toInteger())/60)} Minutes"
    println msgToSlack

    //"View at ${device}" 
    //println device.error.@message
}      
    return msgToSlack.toString()
}

我在此函数中所做的工作是解析卷曲到API并通过webhook接收结果后得到的XML文件。然后,我想解析文档以获取某些值,以通过slack发送该函数,但该函数运行良好,但是当我调用该函数时,我会得到一个

    in field groovy.lang.GString.values
    in object org.codehaus.groovy.runtime.GStringImpl@684e4781
    in field groovy.lang.Closure.delegate
    in object org.jenkinsci.plugins.workflow.cps.CpsClosure2@66757440
    in field org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.closures
    in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@16a73957
    in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@16a73957
Caused: java.io.NotSerializableException: groovy.util.slurpersupport.Attributes```

Any information leading me to the right direction would help! Thanks so much.

0 个答案:

没有答案