Best/most idiomatic way to do parallel tasks that are largely the same?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Best/most idiomatic way to do parallel tasks that are largely the same?

Adam Paul
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

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/b7a18396-5e0b-467c-8e08-9bfcbb1d7e33%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...