从Jenkins Pipeline调用Job DSL

时间:2017-01-11 10:40:34

标签: jenkins jenkins-pipeline jenkins-job-dsl

我需要从管道触发Jenkins Job DSL(具体来说,我需要模仿从工作空间和行为中读取定义文件),但作业dsl插件还没有在管道步骤列表中。我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:6)

Job DSL维基显示如何将作业DSL作为管道步骤运行:https://github.com/jenkinsci/job-dsl-plugin/wiki/User-Power-Moves#use-job-dsl-in-pipeline-scripts

node {
  jobDsl scriptText: 'job("example-2")'

  jobDsl targets: ['jobs/projectA/*.groovy', 'jobs/common.groovy'].join('\n'),
       removedJobAction: 'DELETE',
       removedViewAction: 'DELETE',
       lookupStrategy: 'SEED_JOB',
       additionalClasspath: ['libA.jar', 'libB.jar'].join('\n')
}