why is the groovy code failing in jenkins?

2,257 views
Skip to first unread message

ok999

unread,
Apr 21, 2016, 4:33:45 PM4/21/16
to Jenkins Users
This a very basic test code for the pipleine job


node('windows') {    
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'cca9c557-65b8-4c72-9176-f78d', url: 'g...@github.com:SomeProjects/trobocopy.git']]])


def pathMap = ['folder1':'dst1', 'folder2':'dst2', 'folder3':'dst3', 'folder4':'dst4'] 
  pathMap.each { path, dir -> 
       bat "xcopy %cd%${path} C:\\${dir} /E /Y /V" 
         }
}


The jenkins console shows 

[Pipeline] End of Pipeline
java.io.NotSerializableException: java.util.LinkedHashMap$Entry
	at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
	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:343)
	at java.util.HashMap.writeObject(HashMap.java:1129)
	at sun.reflect.GeneratedMethodAccessor28.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)



Caused by: an exception which occurred:
	in field locals
	in field parent
	in field capture
	in field def
	in field closures
	in object org.jenkinsci.plugins.workflow.cps.CpsThreadGroup@4d0c20da
Finished: FAILURE

Patrick Wolf

unread,
Apr 21, 2016, 6:49:37 PM4/21/16
to jenkins...@googlegroups.com
There is a well known problem with .each in Pipeline right now that Kohsuke is working on. There are many comments here:


--
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-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/cbe33a56-beab-414f-9302-8044e1e1a8f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Patrick Wolf
Sr. Product Manager
CloudBees

ok999

unread,
Apr 22, 2016, 11:03:40 AM4/22/16
to Jenkins Users
Is this issue intermittent by any chance ? I thought i got it working yesterday (the looping part) thanks to stackoverflow but it wont perform the loop today (on a friday!!!) 


node('windows') {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'cca9c557-65b8-4c72-9176-f78d91c22907', url: 'g...@github.com:RocketScienceProjects/testrobocopy.git']]])

def paths = ['folder1', 'folder2', 'folder3']
def dirs = ['dst1', 'dst2', 'dst3']
   [paths, dirs].transpose().each { pd ->
     def path = pd[0]
     def dir = pd[1]
      bat "xcopy %cd%\\${path} C:\\${dir} /E /Y /V"
      bat "(robocopy %cd%\\${path} C:\\${dir}\\temp lab.conf) ^& IF %ERRORLEVEL% LEQ 7 exit 0"
    }
 }


PS: please dont worry abt the batch commands, they doesnt make sense. i am just trying to get the loop rolling :)

Daniel Beck

unread,
Apr 22, 2016, 5:03:20 PM4/22/16
to jenkins...@googlegroups.com

> On 22.04.2016, at 17:03, ok999 <nirish...@gmail.com> wrote:
>
> Is this issue intermittent by any chance ? I thought i got it working yesterday (the looping part) thanks to stackoverflow but it wont perform the loop today (on a friday!!!)

No. However, there was a version of the 'Pipeline: Groovy' plugin (2.0) in which this was fixed, unfortunately this resulted in more severe problems, so it had to be reverted in 2.1.

https://wiki.jenkins-ci.org/display/JENKINS/Pipeline+Groovy+Plugin

Reply all
Reply to author
Forward
0 new messages