Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invoke Job DSL from Jenkins Pipeline

I need to trigger Jenkins Job DSL from pipeline (specifically, i need to mimic 'read definition file from workspace' behavior), but the job dsl plugin isn't yet on pipeline steps list. How can i achieve that?

like image 636
Etki Avatar asked Jan 11 '17 10:01

Etki


People also ask

What is DSL in Jenkins pipeline?

DSL stands for Domain Specific Language. You can describe your jobs in Jenkins using a Groovy Based Language.

What is the difference between Jenkins pipelines and the job DSL?

There is no need to "seed" jobs using Pipeline as there is with Job DSL since the Pipeline is the job itself. With Job DSL, it's just a script that creates other jobs. With Pipeline, you have features such as a parameterized manual input step, allowing you specify logic midstream within the pipeline.


1 Answers

The Job DSL wiki shows how to run Job DSL as a Pipeline step: 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')
}
like image 167
daspilker Avatar answered Sep 19 '22 16:09

daspilker