title: Jenkins Pipeline Groovy pass in array to function
body: <p>I'm setting an array like this</p>
  
  <pre><code>def tags = [
      "zookeeper",
      "postgres",
      "postgres-maps",
      "kudu-master",
      "redis-master",
      "consul",
      "dcos-bootstrap"]
  </code></pre>
  
  <p>I'm trying to pass it into a function like</p>
  
  <pre><code> run_linux("${tags}")
  </code></pre>
  
  <p>My function looks like</p>
  
  <pre><code>def run_linux(tags) {
    def tasks = [:]
  
    for (i = 0; i &lt; tags.size(); i++) {
      def tag = "${tags[i]}"
      tasks["${tag}"] = {
         stage ("${tag}"){
              sh ..
         }
      }
  </code></pre>
  
  <p>So what it looks like in jenkins is this</p>
  
  <pre><code>[Pipeline] [[] stage
  [Pipeline] [[] { ([)
  [Pipeline] [z] stage
  [Pipeline] [z] { (z)
  [Pipeline] [o] stage
  [Pipeline] [o] { (o)
  [Pipeline] [k] stage
  [Pipeline] [k] { (k)
  </code></pre>
  
  <p>It seems to be treating what got passed in as a string not an array. </p>