diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 0878724a2..e5845313d 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -307,6 +307,12 @@ def trigger_parameterized_builds(parser, xml_parent, data): :arg str property-file: Use properties from file (optional) :arg bool fail-on-missing: Blocks the triggering of the downstream jobs if any of the files are not found in the workspace (default 'False') + :arg bool use-matrix-child-files: Use files in workspaces of child + builds (default 'False') + :arg str matrix-child-combination-filter: A Groovy expression to filter + the child builds to look in for files + :arg bool only-exact-matrix-child-runs: Use only child builds triggered + exactly by the parent. :arg str file-encoding: Encoding of contents of the files. If not specified, default encoding of the platform is used. Only valid when 'property-file' is specified. (optional) @@ -368,6 +374,17 @@ def trigger_parameterized_builds(parser, xml_parent, data): if 'file-encoding' in project_def: XML.SubElement(params, 'encoding' ).text = project_def['file-encoding'] + if 'use-matrix-child-files' in project_def: + # TODO: These parameters only affect execution in + # publishers of matrix projects; we should warn if they are + # used in other contexts. + XML.SubElement(params, "useMatrixChild").text = ( + str(project_def['use-matrix-child-files']).lower()) + XML.SubElement(params, "combinationFilter").text = ( + project_def.get('matrix-child-combination-filter', '')) + XML.SubElement(params, "onlyExactRuns").text = ( + str(project_def.get('only-exact-matrix-child-runs', + False)).lower()) if ('current-parameters' in project_def and project_def['current-parameters']): XML.SubElement(tconfigs, pt_prefix + 'CurrentBuildParameters') diff --git a/tests/publishers/fixtures/trigger_parameterized_builds004.xml b/tests/publishers/fixtures/trigger_parameterized_builds004.xml new file mode 100644 index 000000000..ae2419236 --- /dev/null +++ b/tests/publishers/fixtures/trigger_parameterized_builds004.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<project> + <publishers> + <hudson.plugins.parameterizedtrigger.BuildTrigger> + <configs> + <hudson.plugins.parameterizedtrigger.BuildTriggerConfig> + <configs> + <hudson.plugins.parameterizedtrigger.FileBuildParameters> + <propertiesFile>version.prop</propertiesFile> + <failTriggerOnMissing>false</failTriggerOnMissing> + <useMatrixChild>true</useMatrixChild> + <combinationFilter/> + <onlyExactRuns>false</onlyExactRuns> + </hudson.plugins.parameterizedtrigger.FileBuildParameters> + </configs> + <projects>other_job</projects> + <condition>ALWAYS</condition> + <triggerWithNoParameters>false</triggerWithNoParameters> + </hudson.plugins.parameterizedtrigger.BuildTriggerConfig> + </configs> + </hudson.plugins.parameterizedtrigger.BuildTrigger> + </publishers> +</project> diff --git a/tests/publishers/fixtures/trigger_parameterized_builds004.yaml b/tests/publishers/fixtures/trigger_parameterized_builds004.yaml new file mode 100644 index 000000000..62810dccb --- /dev/null +++ b/tests/publishers/fixtures/trigger_parameterized_builds004.yaml @@ -0,0 +1,6 @@ +publishers: + - trigger-parameterized-builds: + - project: + - other_job + property-file: version.prop + use-matrix-child-files: True diff --git a/tests/publishers/fixtures/trigger_parameterized_builds005.xml b/tests/publishers/fixtures/trigger_parameterized_builds005.xml new file mode 100644 index 000000000..27c113c02 --- /dev/null +++ b/tests/publishers/fixtures/trigger_parameterized_builds005.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<project> + <publishers> + <hudson.plugins.parameterizedtrigger.BuildTrigger> + <configs> + <hudson.plugins.parameterizedtrigger.BuildTriggerConfig> + <configs> + <hudson.plugins.parameterizedtrigger.FileBuildParameters> + <propertiesFile>version.prop</propertiesFile> + <failTriggerOnMissing>false</failTriggerOnMissing> + <useMatrixChild>true</useMatrixChild> + <combinationFilter>FOO && BAR</combinationFilter> + <onlyExactRuns>true</onlyExactRuns> + </hudson.plugins.parameterizedtrigger.FileBuildParameters> + </configs> + <projects>other_job</projects> + <condition>ALWAYS</condition> + <triggerWithNoParameters>false</triggerWithNoParameters> + </hudson.plugins.parameterizedtrigger.BuildTriggerConfig> + </configs> + </hudson.plugins.parameterizedtrigger.BuildTrigger> + </publishers> +</project> diff --git a/tests/publishers/fixtures/trigger_parameterized_builds005.yaml b/tests/publishers/fixtures/trigger_parameterized_builds005.yaml new file mode 100644 index 000000000..2f1bcc94a --- /dev/null +++ b/tests/publishers/fixtures/trigger_parameterized_builds005.yaml @@ -0,0 +1,8 @@ +publishers: + - trigger-parameterized-builds: + - project: + - other_job + property-file: version.prop + use-matrix-child-files: True + matrix-child-combination-filter: "FOO && BAR" + only-exact-matrix-child-runs: True