0

I have 'n' no. of jobs, which I want to start simultaneously. Is it feasible in Jenkins? I tried using DSL plugin, work flow plugin. I have used 'parallel' method. I have my list of jobnames in an array/list and want to run them parallel. Please help.

Currently I'm iterating the jobnames in an array, so they start one by one, instead I want them to start parallel. How this can be achieved ?

StephenKing
  • 36,187
  • 11
  • 83
  • 112
DevOps Junky
  • 287
  • 1
  • 5
  • 22
  • What's your pipeline code? That works pretty fine. See e.g. [this article](https://www.cloudbees.com/blog/parallelism-and-distributed-builds-jenkins). – StephenKing Jul 15 '16 at 11:30

4 Answers4

1

This will fullfill your requirement

    GParsPool.withPool(NO.OF.THREADS){
        sampleList.eachParallel{
            callYourMethod(it)
        }
    }
Pbr_Prajwal
  • 46
  • 1
  • 3
0

I've done this before. The solution I found that worked for me was through use of upstream/downstream jobs, visualizing using the Build Pipeline Plugin.

Essentially, create one blank 'bootstrap' job that you use to kick off all the jobs that you require to run in parallel, with each of the parallel jobs having the bootstrap job as an upstream trigger.

Benjamin
  • 1,221
  • 11
  • 28
0

The option that we have been using to trigger multiple jobs in parallel is the https://wiki.jenkins-ci.org/display/JENKINS/Parameterized+Trigger+Plugin we then have a master job that just needs a comma separated list of all the jobs to call.

0

In my opinion, the best way (it will up your personal skill ;-) ) is to use Jenkins Pipeline !!

You can find a simple example of code just below

// While you can't use Groovy's .collect or similar methods currently, you can
// still transform a list into a set of actual build steps to be executed in
// parallel.

// Our initial list of strings we want to echo in parallel
def stringsToEcho = ["a", "b", "c", "d"]

// The map we'll store the parallel steps in before executing them.
def stepsForParallel = [:]

// The standard 'for (String s: stringsToEcho)' syntax also doesn't work, so we
// need to use old school 'for (int i = 0...)' style for loops.
for (int i = 0; i < stringsToEcho.size(); i++) {
    // Get the actual string here.
    def s = stringsToEcho.get(i)

    // Transform that into a step and add the step to the map as the value, with
    // a name for the parallel step as the key. Here, we'll just use something
    // like "echoing (string)"
    def stepName = "echoing ${s}"

    stepsForParallel[stepName] = transformIntoStep(s)
}

// Actually run the steps in parallel - parallel takes a map as an argument,
// hence the above.
parallel stepsForParallel

// Take the string and echo it.
def transformIntoStep(inputString) {
    // We need to wrap what we return in a Groovy closure, or else it's invoked
    // when this method is called, not when we pass it to parallel.
    // To do this, you need to wrap the code below in { }, and either return
    // that explicitly, or use { -> } syntax.
    return {
        node {
            echo inputString
        }
    }
}  
Sebastien
  • 1,057
  • 8
  • 7