问题
I created this Groovy JobDSLs script to generate a new Jenkins jobs.
List screen = [["AAA", "Description" ],["AAA", "Description" ]]
for (item in screen) {
job(item[0]) {
description(item[1])
steps {
shell('command ...')
}
}
}
Is there a way how to tell JobDSL plugin to not create a job in the List, if it already exists in Jenkins? I don't want to keep to separate files for generating new jobs. One file for new jobs and one file for all existing jobs.
回答1:
If a job definition does not change, Job DSL does not update a job.
If a job definition changes and you want to ignore these changes, select the Action for existing jobs and views: Ignore changes
option in the Process Job DSLs
build step.
If you are doing this programatically with jobDsl in groovy pipeline, it may look like this:
jobDsl targets: 'jobs/**/seed.groovy', ignoreExisting: true
来源:https://stackoverflow.com/questions/41285489/jobdsl-create-a-new-job-if-it-doesnt-exist-in-jenkins-already