How to run build steps in a loop from csv file

688 views
Skip to first unread message

ok nj

unread,
Sep 24, 2015, 2:21:45 AM9/24/15
to Jenkins Users

I'm trying to create a job that will run a certain flow multiple times, each time with different parameters on multiple nodes in parallel. I have a csv file, on which each line contains the requested parameters for a run. I tried using multi configuration job, and I read about the dynamic axis, but I don't quite understand how to use it with the data from my csv file. I also saw build flow and workflow plugins, but again, I couldn't understand how to use it with my csv file.

I'd appreciate if anyone can give me ideas how to solve this.

Thanks in advance,

Sivan

Victor Martinez

unread,
Sep 24, 2015, 4:30:07 AM9/24/15
to Jenkins Users
Hi,

 If you use JobDSL plugin then you might use something like the below snippet:

job ("generated.job") {   
  readFileFromWorkspace('your_csv_file.csv').eachLine { line ->
    line.split(',').each { value ->
         steps {
        shell ("echo 'running my shell ${value}'")
      }
    }
  }
}

The above script will create a Jenkins Job, called generated.job, with a bunch of shell steps (each one based on a different value).

Further details:

I hope it helps

Cheers
Reply all
Reply to author
Forward
0 new messages