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 > <https://github.com/jenkinsci/workflow-cps-plugin#technical-design> 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 > 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.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.BlockMarshaller.doWriteObject(BlockMarshaller.java:65) > at > org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56) > at > org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50) > at > org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179) > at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344) > at java.util.HashMap.internalWriteEntries(HashMap.java:1785) > at java.util.HashMap.writeObject(HashMap.java:1362) > at sun.reflect.GeneratedMethodAccessor271.invoke(Unknown Source) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:498) > at > org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:271) > at > org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:976) > 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.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:58) > at > org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:111) > at > org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.writeObject(RiverWriter.java:132) > at > org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:429) > at > org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:408) > at > org.jenkinsci.plugins.workflow.cps.CpsStepContext$3.onSuccess(CpsStepContext.java:488) > at > org.jenkinsci.plugins.workflow.cps.CpsStepContext$3.onSuccess(CpsStepContext.java:484) > at > org.jenkinsci.plugins.workflow.cps.CpsFlowExecution$4$1.run(CpsFlowExecution.java:627) > at > org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$1.run(CpsVmExecutorService.java:35) > at > java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) > at java.util.concurrent.FutureTask.run(FutureTask.java:266) > at > hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112) > at > jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) > at > java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) > at java.util.concurrent.FutureTask.run(FutureTask.java:266) > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) > at java.lang.Thread.run(Thread.java:745) > Caused by: an exception which occurred: > in field collector > in field abnormal > in field outcome > in field body > in field step > in field thread > in field this$0 > in field returnAddress > in field parent > in field caller > in field parent > in field parent > in field capture > in field def > in field closures > in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@5a569b9f > > > > Global library code in a github repo under /vars/ecs.groovy, if body is > replaced with hello-world or similar works fine, but can't seem to execute > the below Java/groovy: > #!groovy > @Grab(group='com.amazonaws', module='aws-java-sdk-ecs', version='1.11.40') > import com.amazonaws.regions.Region; > import com.amazonaws.regions.Regions; > import com.amazonaws.services.ecs.AmazonECSClient; > import com.amazonaws.services.ecs.model.DescribeServicesRequest; > import com.amazonaws.services.ecs.model.DescribeServicesResult; > import com.cloudbees.groovy.cps.NonCPS; // is this necessary? > @NonCPS // doesn't seem to have an effect? > boolean waitForEcs(final String cluster, final String serviceName, final > int taskDefinitionRevision) { > return new AmazonECSClient().withRegion(Region.getRegion(Regions.US_WEST_2 > )) > .describeServices(new DescribeServicesRequest().withCluster(cluster). > withServices(serviceName)) > .getServices().stream().anyMatch(s -> > s.getEvents().get(0).getMessage().equals("(service " + serviceName + ") > has reached a steady state.") > && s.getServiceName().equals(serviceName) > && s.getDeployments().stream().anyMatch( > d -> d.getStatus().equals("PRIMARY") > && d.getRunningCount() == 2 > && d.getTaskDefinition().contains(serviceName + '_' + cluster + ':' + > taskDefinitionRevision))); > } > -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/6d465a2b-196d-4336-ae58-86e7b5381f57%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.