Hi all,

I've been trying out the workflow plugin after watching the 
pimp-your-continuous-delivery-pipeline-with-jenkins-workflow-wjax-14 
<http://www.slideshare.net/cloudbees/pimp-your-continuous-delivery-pipeline-with-jenkins-workflow-wjax-14>
 demo. 
And in one of the slides (24), there is an example of a for loop that looks 
to iterate over a list of hostnames. I've assumed that hostnames is a list

def hostnames = ["192.168.0.1", "192.168.0.2"]
for( def hostname: hostnames ) {
    sh "ssh ${hostname} ..."
  }

I'm wondering if anyone can help with my usage of arrays/lists. I'm getting 
the following errors when I try the above:

java.io.NotSerializableException: java.util.AbstractList$Itr


Now I understand from the docs 
(https://github.com/jenkinsci/workflow-plugin/blob/master/TUTORIAL.md#serialization-of-local-variables)
 that some variables can't be serialized before a "sh" step might happen, but 
as I'm new to groovy I'm struggling to understand how the above might be 
achieved. I've tried in a method and inline as suggested.


The workaround I have at the moment is


def hostnames = ["192.168.0.1", "192.168.0.2"]
for( int i = 0; i < hostnames.size(); i++) {
  sh "ssh ${hostnames.get(i)} ..."
}

Any pointers would be much appreciated

Thanks
Robin

-- 
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/c779e2f2-8f64-4191-a77a-f6f6699238a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to