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?
DSL stands for Domain Specific Language. You can describe your jobs in Jenkins using a Groovy Based Language.
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.
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')
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With