2017-11-10 9 views
0

Jenkinsパイプラインを条件付きで並列実行することは可能ですか?だから、すべてのステージを並行して実行する完全なビルドがありますが、ステージの2/5しか実行したくないと言うことができます。これは可能ですか?誰もこの構文がどのように見えるか考えていますか?ここに私のGroovyスクリプトです:Jenkins並列パイプライン条件付きフローは可能ですか?

def call() { 
    def my_automation = load("my-lib/groovies/my_automation.groovy") 
    parallel thing1: { 
    stage('thing1'){ 
     my_automation.my_func("thing1") 
    }}, 
    thing2: { 
    stage('thing2'){ 
     my_automation.my_func("thing2") 
    }}, thing3: { 
    stage('thing3'){ 
     my_automation.my_func("thing3") 
    }}, thing4: { 
    stage('thing4'){ 
     my_automation.my_func("thing4") 
    }}, thing5: { 
    stage('thing5'){ 
     my_automation.my_func("thing5") 
    }}, thing6: { 
    stage('thing6'){ 
     my_automation.my_func("thing6") 
    }}, thing7: { 
    stage('thing7') { 
     my_automation.my_func("thing7") 
    } 
    } 
}return this; 

しかし、この種のものを探して:

for(all things defined, run them at once in parallel) 
{ 
etc... 
} 

が可能、このですか?

答えて

0

条件付きで処理するのではなく、並列に渡すものを条件付きで定義する必要があります。あなたは、並列ステップにそれを渡し、その後、あなたがマップで実行したいもののマップを構築するためのループを使用します。

def branches = [:] 

for (int i = 0; i < 4 ; i++) { 
     int index = i 

     branches["thing${index}"] = { 
      stage("thing${index}") { 
       node ('label_example'){ 
        my_automation.my_func("thing${index}") 
       } 
      } 
     } 

} 

parallel branches 

使用ロジックが内側にしたい場合は、マップに何かを追加スキップします。これは構文チェックやテストではありませんが、そのアイデアを得るべきです。

関連する問題