Requirement to run a set of tasks for a build in parallel, The tasks for the build are dynamic it may change

16 views
Skip to first unread message

pbasan...@gmail.com

unread,
Apr 8, 2019, 6:42:52 AM4/8/19
to Jenkins Users
Hi All,


I have a requirement to run a set of tasks for a build in parallel, The tasks for the build are dynamic it may change. I need some help in the implementation of that below are the details of it.
For Component 1 : 2 jobs need to trigger in parallel 
for Component 2 : 4 jobs need to trigger in parallel 
For Component 3 : 3 jobs need to trigger in parallel 

Regards,
Basanta

Akshay Paturkar

unread,
Apr 8, 2019, 7:13:04 AM4/8/19
to Jenkins Users
Hi Basanta ,
you can try custom implementation for parallal stage something like below.

def parallelConverge(instanceNames, targets, runPhase, customParam) {
    def parallelNodes = [:]
    for (instance in instanceNames) {
        def moduleName = instance
        else {
            parallelNodes[moduleName] = this.getNodeForInstance(moduleName, targets)
        }
    }
    parallel parallelNodes
}

and 

Closure getNodeForInstance(instanceName, target) {
    return {
        try {
            stageName = "Build_" + instanceName
            stage(stageName) {
                
                        {
                            else {
                                sh "ant -DBUILD_MODULES='${instanceName}' -Dpatch.number='' -buildfile ${BUILD_ROOT}/build/build.xml " + target
                            }
                        }
            }
        
        catch (e) {
            println 'exception occured at module' + instanceName + "exception occured is" + e
        }
    }
}

Parameterise method as per your requirements .

Hope it willl solve your problem 

pbasan...@gmail.com

unread,
Apr 8, 2019, 9:50:27 AM4/8/19
to Jenkins Users
Thanks for the Info ..
I am new to this Pipeline so not able to undesrstand.. 
Need your help for the full code that can be used ..
Reply all
Reply to author
Forward
0 new messages