diff --git a/jenkins_jobs/modules/builders.py b/jenkins_jobs/modules/builders.py index d860e2c3a..93cbfe1a4 100644 --- a/jenkins_jobs/modules/builders.py +++ b/jenkins_jobs/modules/builders.py @@ -2207,10 +2207,10 @@ def dsl(parser, xml_parent, data): Requires the Jenkins :jenkins-wiki:`Job DSL plugin `. - :arg str script-text: dsl script which is Groovy code (required if target + :arg str script-text: dsl script which is Groovy code (Required if targets is not specified) - :arg str target: Newline separated list of DSL scripts, located in the - Workspace. Can use wildcards like 'jobs/\*\*/\*.groovy' (required + :arg str targets: Newline separated list of DSL scripts, located in the + Workspace. Can use wildcards like 'jobs/\*/\*/\*.groovy' (Required if script-text is not specified) :arg str ignore-existing: Ignore previously generated jobs and views :arg str removed-job-action: Specifies what to do when a previously @@ -2238,11 +2238,21 @@ def dsl(parser, xml_parent, data): dsl = XML.SubElement(xml_parent, 'javaposse.jobdsl.plugin.ExecuteDslScripts') + if 'target' in data: + if 'targets' not in data: + logger.warn("Converting from old format of 'target' to new " + "name 'targets', please update your job definitions.") + data['targets'] = data['target'] + else: + logger.warn("Ignoring old argument 'target' in favour of new " + "format argument 'targets', please remove old " + "format.") + if data.get('script-text'): XML.SubElement(dsl, 'scriptText').text = data.get('script-text') XML.SubElement(dsl, 'usingScriptText').text = 'true' - elif data.get('target'): - XML.SubElement(dsl, 'targets').text = data.get('target') + elif data.get('targets'): + XML.SubElement(dsl, 'targets').text = data.get('targets') XML.SubElement(dsl, 'usingScriptText').text = 'false' else: raise MissingAttributeError(['script-text', 'target']) diff --git a/tests/builders/fixtures/dsl-002.xml b/tests/builders/fixtures/dsl-002.xml new file mode 100644 index 000000000..555073e4b --- /dev/null +++ b/tests/builders/fixtures/dsl-002.xml @@ -0,0 +1,14 @@ + + + + + jobs/*/*/*.groovy + false + true + IGNORE + IGNORE + JENKINS_ROOT + + + + diff --git a/tests/builders/fixtures/dsl-002.yaml b/tests/builders/fixtures/dsl-002.yaml new file mode 100644 index 000000000..5542864b9 --- /dev/null +++ b/tests/builders/fixtures/dsl-002.yaml @@ -0,0 +1,4 @@ +builders: + - dsl: + targets: "jobs/*/*/*.groovy" + ignore-existing: true