2017-12-03 13 views
1

제 젠킨스 파이프 라인 작업을 생성하는 DSL 스크립트가 있습니다.Jenkins가 DSL을 사용하여 multibranchPipelineJob에 자식 서브 모듈을 추가합니다.

String[] repos = 
    ['xxx']  

for (int i = 0; i < repos.length; i++) { 
    repoName = repos[i];  
    multibranchPipelineJob('PIPELINE-'+repoName) { 
     branchSources { 
      git { 
       remote('[email protected]:yyy/'+repoName+'.git') 
       credentialsId('112233445566') 
      } 
     } 
     description ("""<p> <b>generate by DSL - DO NOT CHANGE Manually </b> <p>""") 
     triggers { 
      periodic(2) 
     } 
     orphanedItemStrategy { 
      discardOldItems { 
       numToKeep(0) 
       daysToKeep(0) 
      } 
     } 
    } 
} 

나는 추가 행동 추가하려는 - 고급 서브 모듈은 행동들 enter image description here

답변

1

여기에 하위 모듈 태그 및 분기 발견을 추가하는 스크립트가 있습니다.

multibranchPipelineJob('example') { 
    branchSources {  
    branchSource { 
     source {   
     git { 
      credentialsId('1111-2222-3333') 
      remote('[email protected]:xxx/yyyy.git') 

      traits {    
      submoduleOptionTrait { 
       extension { 
       disableSubmodules(false) 
       recursiveSubmodules(true) 
       trackingSubmodules(false) 
       reference(null) 
       timeout(null) 
       parentCredentials(true) 
       } 
      } 

      cloneOptionTrait { 
       extension { 
       shallow (false) 
       noTags (false) 
       reference (null) 
       depth(0) 
       honorRefspec (false) 
       timeout (10) 
       } 
      } 
      } 
     } 
     } 
    } 
    } 

    triggers { 
      periodic(2) 
     } 

configure { 
     def traits = it/sources/data/'jenkins.branch.BranchSource'/source/traits 
     traits << 'jenkins.plugins.git.traits.BranchDiscoveryTrait' {} 
    } 
} 
2

"추가 행동을"지원하지 않는 DSL 내장,하지만 Automatically Generated DSL을 수행합니다

multibranchPipelineJob('example-mbp2') { 
    branchSources { 
    branchSource { 
     source { 
     git { 
      id('bbedfd29-5bb0-4c13-b040-0dbd0d19345b') 
      remote('https://github.com/jenkinsci/job-dsl-plugin.git') 
      traits { 
      submoduleOptionTrait { 
       extension { 
       disableSubmodules(false) 
       recursiveSubmodules(true) 
       trackingSubmodules(false) 
       reference(null) 
       timeout(null) 
       parentCredentials(true) 
       } 
      } 
      } 
     } 
     } 
    } 
    } 
} 
+0

고마워, 그게 좋겠지 만 어떤 이유로 나는 자격 증명을 추가 할 수 없어 ..., 어떤 생각? OK, credentialsID가 –

+0

인 ID를 업데이트해야하는 문제를 발견했습니다. 2 가지 질문이 있습니다. 어떻게 Discover 분기 섹션을 추가 할 수 있으며 태그를 복제하고 싶습니다. 어떤 문서도 찾을 수 없습니다. –