Or, if it's any easier, how can I get a list of folders in a Jenkins
pipeline?
On Thursday, October 17, 2019 at 2:45:58 PM UTC-4, ZillaYT wrote:
>
> I have the following function defined in a pipeline.
>
> private boolean isFolder(Item j) {
> return j.getClass().getName() ==
> "com.cloudbees.hudson.plugins.folder.Folder"
> }
>
>
> When I run it, I get
>
> an exception which occurred: in field
> com.cloudbees.groovy.cps.impl.BlockScopeEnv.locals in object
> com.cloudbees.groovy.cps.impl.BlockScopeEnv@ad9ba3c in field
> com.cloudbees.groovy.cps.impl.CpsClosureDef.capture in object
> com.cloudbees.groovy.cps.impl.CpsClosureDef@a44ee1a in field
> com.cloudbees.groovy.cps.impl.CpsClosure.def in object
> org.jenkinsci.plugins.workflow.cps.CpsClosure2@13b12418 in field
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.closures in object
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@554cc3b1 in object
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@554cc3b1 Caused:
> java.io.NotSerializableException: com.cloudbees.hudson.plugins.folder.Folder
> at
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:926)
> at
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:568)
> 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:1793) at
> java.util.HashMap.writeObject(HashMap.java:1363) at
> sun.reflect.GeneratedMethodAccessor65.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.JDKSpecific$SerMethods.callWriteObject(JDKSpecific.java:156)
> at
> org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:191)
> at
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1028)
> at
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
> at
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
> at
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
> at
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
> at
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
> at
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
> at
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
> at
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
> at
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
> at
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1019)
> at
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
> 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:1793) at
> java.util.HashMap.writeObject(HashMap.java:1363) at
> sun.reflect.GeneratedMethodAccessor65.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.JDKSpecific$SerMethods.callWriteObject(JDKSpecific.java:156)
> at
> org.jboss.marshalling.reflect.SerializableClass.callWriteObject(SerializableClass.java:191)
> at
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1028)
> at
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
> at
> org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1082)
> at
> org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1040)
> at
> org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:920)
> 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.lambda$writeObject$0(RiverWriter.java:144)
> at
> org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:237)
> at
> org.jenkinsci.plugins.workflow.support.pickles.serialization.RiverWriter.writeObject(RiverWriter.java:143)
> at
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:523)
> at
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgram(CpsThreadGroup.java:499)
> at
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.saveProgramIfPossible(CpsThreadGroup.java:486)
> at
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:410)
> at
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$200(CpsThreadGroup.java:93)
> at
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:282)
> at
> org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:270)
> at
> org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:66)
> at java.util.concurrent.FutureTask.run(FutureTask.java:266) at
> hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
> at
> jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
> at
> jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
> 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:1149)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> at java.lang.Thread.run(Thread.java:748) Finished: FAILURE
>
> Is there a better/different way to check if an item is a folder?
>
>
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-users/05feb895-a373-4e99-838c-639a19712c53%40googlegroups.com.