Re: How to diagnose java.io.NotSerializableException: org.codehaus.groovy.control.ErrorCollector errors?

2017-08-27 Thread Baptiste Mathus
IMO you should not try and use Pipeline scripting like you can do standard
Groovy programming for many reasons.

If you want to use Groovy, then put the necessary code chunk in a pure
.groovy file in your project's sources. This will allow you to test and use
it outside Jenkins and avoid hitting issues related to CPS [1]
serialization in the same go.
I understand the natural desire to want to use full Groovy programming
features, but really Pipeline is an orchestration technology so trying to
keep it only for it is a good thing.

Generally, this is somehow related to the "Use Jenkins Less
"
rationale people will have the pleasure to see at Jenkins World in a few
days (still time to come! :-)): you don't want to tie everything to  your
CI/CD system.

My 2 cents

Cheers!
[1] Note for those wondering what that CPS thing is: we already explained
in more details in some previous answers that this *beast* isn't only that
thing that gets in the way, it's also the central piece that provides
restartability to Pipelines.

2017-08-22 3:05 GMT+02:00 Nick Mellor :

> Quick finding-- these errors have generally meant some problem with my
> source code. One thing I note is that variables scoped at script level seem
> to cause this error. Wrap them in a method and the problem disappears. So
> use
>
> def gitPipelineUser() {
>'svcx_git_user'
> }
>
>  rather than
>
> def gitPipelineUser = 'svc_git_user'
>
> This is probably not the only reason you might get this error, but it's
> one possible thing to check.
>
> Cheers,
>
> Nick
>
>
> On Friday, 7 October 2016 09:37:29 UTC+11, John Hovell wrote:
>>
>> Quick question how to diagnose non-serializable errors, or how to avoid
>> the issue entirely in my case.
>>
>> I thought I could add a @NonCPS annotation
>>  to
>> my method to bypass/disable serialization but adding the annotation does
>> not seem to make any difference in the error I receive.
>>
>> Jenkins is 2.7.4 with latest plugins as of a few days ago.
>>
>> Am I using NonCPS incorrectly or is there a way to translate the below
>> code-snippet to something that is serializable (seems unnecessary in my
>> case but perhaps this is the only option for global libraries?)
>>
>> (Relatedly, would it be simpler to use a bash script to perform the below
>> logic? Is there some parallel/analog for global pipeline libraries for
>> bash? I saw there is support for resources but not files that can be
>> executed)
>>
>> java.io.NotSerializableException: org.codehaus.groovy.control.ErrorCollector
>>  at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
>>  at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>>  at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>>  at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>>  at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>>  at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>>  at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>>  at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>>  at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>>  at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>>  at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>>  at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>>  at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>>  at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>>  at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>>  at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>>  at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>>  at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>>  at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>>  at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>>  at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>>  at 
>> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>>  at 
>> 

Re: How to diagnose java.io.NotSerializableException: org.codehaus.groovy.control.ErrorCollector errors?

2017-08-21 Thread Nick Mellor
Quick finding-- these errors have generally meant some problem with my 
source code. One thing I note is that variables scoped at script level seem 
to cause this error. Wrap them in a method and the problem disappears. So 
use

def gitPipelineUser() {
   'svcx_git_user'
}

 rather than

def gitPipelineUser = 'svc_git_user' 

This is probably not the only reason you might get this error, but it's one 
possible thing to check.

Cheers,

Nick

On Friday, 7 October 2016 09:37:29 UTC+11, John Hovell wrote:
>
> Quick question how to diagnose non-serializable errors, or how to avoid 
> the issue entirely in my case.
>
> I thought I could add a @NonCPS annotation 
>  to my 
> method to bypass/disable serialization but adding the annotation does not 
> seem to make any difference in the error I receive. 
>
> Jenkins is 2.7.4 with latest plugins as of a few days ago.
>
> Am I using NonCPS incorrectly or is there a way to translate the below 
> code-snippet to something that is serializable (seems unnecessary in my 
> case but perhaps this is the only option for global libraries?)
>
> (Relatedly, would it be simpler to use a bash script to perform the below 
> logic? Is there some parallel/analog for global pipeline libraries for 
> bash? I saw there is support for resources but not files that can be 
> executed)
>
> java.io.NotSerializableException: org.codehaus.groovy.control.ErrorCollector
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
>   at 
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
>   at 
> 

How to diagnose java.io.NotSerializableException: org.codehaus.groovy.control.ErrorCollector errors?

2016-10-06 Thread John Hovell
Quick question how to diagnose non-serializable errors, or how to avoid the 
issue entirely in my case.

I thought I could add a @NonCPS annotation 
 to my 
method to bypass/disable serialization but adding the annotation does not 
seem to make any difference in the error I receive. 

Jenkins is 2.7.4 with latest plugins as of a few days ago.

Am I using NonCPS incorrectly or is there a way to translate the below 
code-snippet to something that is serializable (seems unnecessary in my 
case but perhaps this is the only option for global libraries?)

(Relatedly, would it be simpler to use a bash script to perform the below 
logic? Is there some parallel/analog for global pipeline libraries for 
bash? I saw there is support for resources but not files that can be 
executed)

java.io.NotSerializableException: org.codehaus.groovy.control.ErrorCollector
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:967)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:854)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1032)
at 
org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:988)
at