Hello,
Let's say I have a product that needs to build on two different architectures (indeed, I do). The build steps are exactly the same, only the architecture differs. What is the best way to do this in parallel in a pipeline without duplicating the code for each architecture. The example below is simple, but my real world one isn't so much.
eg. instead of:
parallel(
"sparc": {
def arch="sparc"
do_stuff(arch)
do_more_stuff(arch)
},
"i386": {
def arch="i386"
do_stuff(arch)
do_more_stuff(arch)
}
)
There is:
def testList = ["sparc","i386"]
def branches = [:]
for (int i = 0; i < testList.size() ; i++) {
String arch=testList[i]
stage ("branch_${arch}"){
branches["branch_${arch}"] = {
node (){
do_stuff(arch)
do_more_stuff(arch)
}
}
}
}
parallel branches
which works, but I'm wondering if there is a better/more idiomatic way to do this?
Thanks!
Adam