title: Jenkins pipeline, parse csv
body: <p>I've been trying to do a simple parse CSV in a Jenkins pipeline.</p>
  
  <p>My CSV is a simple one consisting of a machine name, its IP address, its subnet mask, its default gateway and its primary DNS server address</p>
  
  <p>so </p>
  
  <pre><code>SystemName,IPAddress,Subnet,DefGate,DNS
  server1,10.10.10.10,255.255.255.0,10.10.10.1,10.10.10.1
  server2,10.10.10.11,255.255.255.0,10.10.10.1,10.10.10.1
  </code></pre>
  
  <p>etc.</p>
  
  <p>My script is just this ( basically want to prove I can read the csv split it by line then split each line on the <code>,</code> and echo the individual values out on a line by line basis) :</p>
  
  <pre><code>   stage('Parse the CSV') {
          steps {
              script {
                  dir ('FolderWhereCSVIsClonedFromGit') {
                      if (fileExists('MyCSV.csv')) {
                          echo ' MyCSV.csv found'
  
                          readFile("MyCSV.csv").eachLine { line, count -&gt;
                              def fields = line.split(',')
                              for(String item: fields) {
                                  println item
                                  println ' you are parsing line : ' + count
                                  }
                                  nodes["line${count}"] = {
                                      node {
                                          echo fields[0] + ': ' + fields[1] + ': ' + fields[2] + ': ' + fields[3] + ': ' + fields[4];
                                      }
                                  }
                      }
                      } else {
                          echo ' Machines.csv Not found. Failing.'
                      }
  </code></pre>
  
  <p>...</p>
  
  <p>Each time the code runs it only returns the first line though it is split correctly any subsequent lines are not parsed and printed to the console. </p>
  
  <p>The Jenkins install is a managed service though I can get additional modules/plugins installed it's the not knowing what to ask for which keeps throwing me. </p>