diff --git a/jenkins_jobs/modules/builders.py b/jenkins_jobs/modules/builders.py index 519c32236..6547de0e0 100644 --- a/jenkins_jobs/modules/builders.py +++ b/jenkins_jobs/modules/builders.py @@ -283,7 +283,7 @@ def trigger_builds(parser, xml_parent, data): Requires the Jenkins :jenkins-wiki:`Parameterized Trigger Plugin `. - :arg str project: the Jenkins project to trigger + :arg list project: the Jenkins project to trigger :arg str predefined-parameters: key/value pairs to be passed to the job (optional) :arg list bool-parameters: @@ -356,6 +356,12 @@ def trigger_builds(parser, xml_parent, data): Examples: + Basic usage with yaml list of projects. + + .. literalinclude:: + /../../tests/builders/fixtures/trigger-builds/project-list.yaml + :language: yaml + Basic usage with passing svn revision through. .. literalinclude:: /../../tests/builders/fixtures/trigger-builds001.yaml @@ -517,7 +523,11 @@ def trigger_builds(parser, xml_parent, data): 'ignore-offline-nodes', True)).lower() projects = XML.SubElement(tconfig, 'projects') - projects.text = project_def['project'] + if isinstance(project_def['project'], list): + projects.text = ",".join(project_def['project']) + else: + projects.text = project_def['project'] + condition = XML.SubElement(tconfig, 'condition') condition.text = 'ALWAYS' trigger_with_no_params = XML.SubElement(tconfig, diff --git a/tests/builders/fixtures/trigger-builds/project-list.xml b/tests/builders/fixtures/trigger-builds/project-list.xml new file mode 100644 index 000000000..12d538c97 --- /dev/null +++ b/tests/builders/fixtures/trigger-builds/project-list.xml @@ -0,0 +1,18 @@ + + + + + + + + + + foo,bar,baz + ALWAYS + false + false + + + + + diff --git a/tests/builders/fixtures/trigger-builds/project-list.yaml b/tests/builders/fixtures/trigger-builds/project-list.yaml new file mode 100644 index 000000000..fe37bc270 --- /dev/null +++ b/tests/builders/fixtures/trigger-builds/project-list.yaml @@ -0,0 +1,7 @@ +builders: + - trigger-builds: + - project: + - "foo" + - "bar" + - "baz" + current-parameters: true