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?
Asked
Active
Viewed 9,214 times
1 Answers
12
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')
}

daspilker
- 8,154
- 1
- 35
- 49
-
2`additionalClasspath` will not work if DSL script security is enabled (Manage Jenkins --> Configure Global Security --> Enable script security for Job DSL scripts ) – Haran Mar 12 '21 at 09:02