首页 > 解决方案 > 具有并行命令的 Jenkins 流水线

问题描述

我有这个基本的詹基斯管道

注意:我省略subJobParams了保持代码更小

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 }

                    )
               }
          }
      }
  }

外部作业没有并行运行?我究竟做错了什么?

标签: jenkinscontinuous-integrationjenkins-pipeline

解决方案


查看Build Flow Plugin文档的并行了解详细信息。要添加,以下是我在管道中使用的代码段。

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
      }
    }
  }
}

推荐阅读