【问题标题】:How can we run two stages in parallel in Jenkins2.0 Pipeline project我们如何在 Jenkins 2.0 Pipeline 项目中并行运行两个阶段
【发布时间】:2017-06-22 23:32:34
【问题描述】:

我们如何在 Jenkins2.0 Pipeline 项目中并行运行两个阶段。 例如:在下面的代码中,我想运行两个阶段以并行运行,即“Build_First_Repo”和“Build_Second_Repo”应该并行运行。

stage "Build_First_Repo"
    node { sh '''echo 'Build first repo'
                 source ~/.bashrc'''
                 export path_to_perl_library="/path/to/perl/lib/perl5/5.8.8"
                 perl -I <include_files> build_first_view.pl --inputfile ${input_params}

        }


 stage "Build_Second_Repo"
    node { sh '''echo 'Build second repo'
                 source ~/.bashrc'''
                 export path_to_perl_library="/path/to/perl/lib/perl5/5.8.8"
                 perl -I <include_files> build_second_view.pl --inputfile ${input_params}

        }

我尝试使用“parallel”关键字,但没有成功。

【问题讨论】:

    标签: jenkins continuous-integration jenkins-pipeline continuous-deployment jenkins-2


    【解决方案1】:

    在声明式管道中,您不能在并行步骤中运行阶段,因为步骤是阶段指令的一部分。声明式流程就像阶段 -> 阶段 -> 步骤 -> 您执行的实际步骤。

    但是,您可以在脚本化管道中实现它。示例如下:

    node(){
        parallel first:{
        stage('stage1'){
            echo 'helloworld'
        }
        },
        second:{
        stage('stage2'){
            echo 'helloworld2'
        }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2022-09-23
      • 1970-01-01
      • 2023-03-22
      • 2020-07-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-20
      • 1970-01-01
      相关资源
      最近更新 更多