我们如何在Jenkins2.0 Pipeline项目中并行运行两个阶段

时间:2017-03-28 08:43:13

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

我们如何在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”关键字,但它没有用。

1 个答案:

答案 0 :(得分:0)

在声明性管道中,您无法在并行步骤中运行阶段,因为步骤是阶段指令的一部分。声明性流程就像阶段一样 - &gt;阶段 - &gt;步骤 - &gt;您执行的实际步骤。

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

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