From 20cd667211cd016c686320f6ce148b8ab249af70 Mon Sep 17 00:00:00 2001 From: Daniel Watkins Date: Thu, 15 Oct 2015 16:45:26 +0100 Subject: [PATCH] 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 --- jenkins_jobs/modules/publishers.py | 17 ++++++++++++++ .../trigger_parameterized_builds004.xml | 23 +++++++++++++++++++ .../trigger_parameterized_builds004.yaml | 6 +++++ .../trigger_parameterized_builds005.xml | 23 +++++++++++++++++++ .../trigger_parameterized_builds005.yaml | 8 +++++++ 5 files changed, 77 insertions(+) create mode 100644 tests/publishers/fixtures/trigger_parameterized_builds004.xml create mode 100644 tests/publishers/fixtures/trigger_parameterized_builds004.yaml create mode 100644 tests/publishers/fixtures/trigger_parameterized_builds005.xml create mode 100644 tests/publishers/fixtures/trigger_parameterized_builds005.yaml 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 @@ + + + + + + + + + version.prop + false + true + + false + + + other_job + ALWAYS + false + + + + + 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 @@ + + + + + + + + + version.prop + false + true + FOO && BAR + true + + + other_job + ALWAYS + false + + + + + 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