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