0

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

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} 

     } 

我试图使用“并行”关键字,但它没有奏效。

回答

0

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

但是,你可以在脚本管道中实现它。样品如下:

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