Pipeline - missing arg causes error: java.io.NotSerializableException: org.codehaus.groovy.util.FastArray

420 views
Skip to first unread message

connor...@velopayments.com

unread,
May 24, 2018, 11:10:52 AM5/24/18
to Jenkins Users

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()
            }
        }
    }
}


Console contains:

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 ...


Jenkins ver. 2.124 
Mac OS Sierra 10.12.6 
Local install on a Macbook Pro

Reinhold Füreder

unread,
May 25, 2018, 2:28:18 AM5/25/18
to jenkins...@googlegroups.com

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

 

 

Reply all
Reply to author
Forward
0 new messages