Reputation: 31
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
Upvotes: 3
Views: 7414
Reputation: 181
Beneath a solution without eachLine closure (works in Jenkins ver. 2.89.3). Some closures like eachLine still seem to be broken in Jenkins.
def nodes = [:]
readFile("input.csv").split('\n').eachWithIndex { line, index ->
def params = line.split(',')
nodes[name] = {
// ...
}
If you don't need the counter, you can use 'each' instead
readFile("input.csv").split('\n').each { line -> ... }
Upvotes: 2
Reputation: 2880
Using the workflow plugin you could read the file, parse the contents with standard groovy then set up your nodes - something like
def nodes = [:]
readFile("myfile.csv").eachLine { line, count ->
def params = line.split(',')
nodes["line${count}"] = {
node {
// do stuff
}
}
}
parallel nodes
if you dont need the count variable you could use splitEachLine instead
def nodes = [:]
readFile("abc.csv").splitEachLine(/,/) { runName, param2, p3 ->
nodes[runName] = {
// dostuff with param2, p3
}
}
Upvotes: 0