I have a pipline using two similar functions, both annotated as NonCPS. First function works, but second always fail with NotSerializable exception.
@NonCPS
def findRuntimeKitVersion (xml) {
def xmlparsed = new XmlSlurper(false,true).parseText(xml)
echo xmlparsed.attributes()['count'] + " files found"
def versionFound
xmlparsed.file.findAll { def fileNode ->
result = [email protected]() =~ /.*-(.*)-RuntimeKit.*/
}.each { runtimeFileNode ->
versionFound = result[0][1]
echo "Found version " + versionFound
}
if (!versionFound) {
error ("Product version was not found")
} else {
return versionFound
}
}
@NonCPS
def findRuntimeKitPath (xml) {
def xmlparsed = new XmlSlurper(false,true).parseText(xml)
echo xmlparsed.attributes()['count'] + " files found"
def href
xmlparsed.file.findAll { def fileNode ->
[email protected]() =~ /.*-(.*)-RuntimeKit.*/
}.each { runtimeFileNode ->
href = [email protected]()
}
if (!href) {
error ("Product path was not found")
} else {
return href
}
}
They are called one after another:
version = findRuntimeKitVersion(xml)
echo "Choosing version " + version
def href = findRuntimeKitPath(xml)
No matter what I do with findRuntimeKitPath
function (even copied code from first one) it always gives NotSerializable exception, but first one always work.
What is the problem here?