useMatrixChild support in parameterized trigger

This change introduces three new options that allow users to configure
the trigger-parameterized-builds publisher to look in matrix child
build workspaces when looking for parameter files.

Change-Id: I6348eb48fd09158f50fb49fb374cb2ce46b29765
This commit is contained in:
Daniel Watkins 2015-10-15 16:45:26 +01:00
parent 46bc9ecab5
commit 20cd667211
5 changed files with 77 additions and 0 deletions

View File

@ -307,6 +307,12 @@ def trigger_parameterized_builds(parser, xml_parent, data):
:arg str property-file: Use properties from file (optional) :arg str property-file: Use properties from file (optional)
:arg bool fail-on-missing: Blocks the triggering of the downstream jobs :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') 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 :arg str file-encoding: Encoding of contents of the files. If not
specified, default encoding of the platform is used. Only valid when specified, default encoding of the platform is used. Only valid when
'property-file' is specified. (optional) 'property-file' is specified. (optional)
@ -368,6 +374,17 @@ def trigger_parameterized_builds(parser, xml_parent, data):
if 'file-encoding' in project_def: if 'file-encoding' in project_def:
XML.SubElement(params, 'encoding' XML.SubElement(params, 'encoding'
).text = project_def['file-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 if ('current-parameters' in project_def
and project_def['current-parameters']): and project_def['current-parameters']):
XML.SubElement(tconfigs, pt_prefix + 'CurrentBuildParameters') XML.SubElement(tconfigs, pt_prefix + 'CurrentBuildParameters')

View File

@ -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>

View File

@ -0,0 +1,6 @@
publishers:
- trigger-parameterized-builds:
- project:
- other_job
property-file: version.prop
use-matrix-child-files: True

View File

@ -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 &amp;&amp; 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>

View File

@ -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