2017-11-10 13 views
0

Jenkins 파이프 라인을 조건부로 병렬로 실행할 수 있습니까? 그래서 병렬로 모든 단계를 실행하는 전체 빌드를 가지고 있지만, 단지 2/5 단계 만 실행하고 싶다고 말하면됩니다 ... 가능 합니다만,이 구문이 어떤 모양인지 알 수 있습니까?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

조건부로 처리하려면 조건부로 병렬로 전달하려는 조건을 조건부로 정의해야합니다. 당신은 당신이지도에서 실행하고자하는 일의지도를 구축하는 for 루프를 사용하는 것이 다음 병렬 단계로 되었 :

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 

를 사용하여 논리를 내부가 원하는 경우지도에 무언가를 추가 건너 . 이것은 문법 검사 나 테스트가 아니지만 아이디어를 얻어야합니다.