title: How to fix NotSerializableException error during Jenkins workflow build?
body: <p>When I run the following code on the Jenkins workflow (Jenkins 1.609.1 ,workflow 1.8)  I get error of 'NotSerializableException' (also below).
  However, if I move the "build job" outside the "for" scope it works fine (the job is activated). Any ideas why this behavior? </p>
  
  <pre><code>node('master') { 
  ws('/opt/test) {
  def file = "/ot.property"
  def line = readFile (file)
  def resultList = line.tokenize()
  for(item in resultList )
    {
  build job: 'testjob_1'
     }
   }
  }
  </code></pre>
  
  <p>Got error:  </p>
  
  <pre><code>Running: End of Workflow 
  java.io.NotSerializableException: java.util.ArrayList$Itr  
      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)  
  
  
  .....
  </code></pre>