spen123
spen123

Reputation: 3524

Jenkins Pipeline With Parallel Command

I have this basic jenkis Pipeline

Note: I omitted subJobParams to keep code smaller

pipeline {
    agent any 
    stages {

        stage('stage1') {
            steps {
                script {
                    parallel (
                                "mongoParallel" : { build job: 'mongo', parameters: subJobParams },
                                "elasticsearchParallel" : { build job: 'elasticsearch', parameters: subJobParams }
                                "redisParallel" : { build job: 'redis', parameters: subJobParams }

                    )
               }
          }
      }
  }

The external jobs are not running in parallel? What am I doing wrong?

Upvotes: 0

Views: 170

Answers (1)

vijay v
vijay v

Reputation: 2076

Check the Build Flow Plugin documentation's parallel for details. To add, below is the snippet that I'm using in my pipelines.

stage('Name') {
  steps {
    script{
      container('tools') {
          parallel job1: {
              build job: 'path/to/the/job', parameters: [string(name: 'command', value: 'command-out')]
          }, job2: {
              build job: 'path/to/the/job', parameters: [string(name: 'command', value: 'command-out')]
          }, job3: {
              build job: 'path/to/the/job', parameters: [string(name: 'command', value: 'command-out')]
          }, job4: {
              build job: 'path/to/the/job', parameters: [string(name: 'command', value: 'command-out')]
          },
          failFast: true
      }
    }
  }
}

Upvotes: 3

Related Questions