I have a pipeline script and encountered a strange groovy error: java.io.NotSerializableException: org.codehaus.groovy.util.FastArray
I narrowed it down to an error in my script, namely that I had failed to pass a value for a particular parameter.
Initially I thought it was to do with scripts in a global library, but the problem is reproducible with a self contained script.
Is this a known bug?
Regards,
Connor
Here's the reproducible:
#!/usr/bin/env groovy
def sayHello() {
echo "Hello from sayHello"
}
def sayHelloInPipelineScriptWithArgs(String myArg, String branch = "master") {
echo "Hello from sayHelloInPipelineScriptWithArgs"
}
pipeline {
agent any
stages {
stage('Stage 1') {
steps {
echo 'Running Stage 1'
// sayHello runs OK
sayHello()
// sayHelloInPipelineScriptWithArgs is above, but I have forgotten to pass a value for the argument
sayHelloInPipelineScriptWithArgs()
}
}
}
}Pipeline] {
[Pipeline] stage
[Pipeline] { (Stage 1)
[Pipeline] echo
Running Stage 1
[Pipeline] echo
Hello from sayHello
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
an exception which occurred:
in field org.codehaus.groovy.runtime.metaclass.MethodSelectionException.methods
in object org.codehaus.groovy.runtime.metaclass.MethodSelectionException@ba293e4
in field com.cloudbees.groovy.cps.impl.BlockScopeEnv.locals
... lots of other lines here ...
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@34de9f29
in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@34de9f29
Caused: java.io.NotSerializableException: org.codehaus.groovy.util.FastArray
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
... lots of other lines here ...Hello Connor,
maybe this gives you some more background on the problem:
Hints: @NonCPS annotation vs. using other (by groovy CPS) supported data types
HTH Reinhold