Added property-multiline for parameterized build trigger plugin
Updated test cases as well, The tag has been introduced after 2.35.2 therefore the parameter is also >=2.35.2 Change-Id: Ie0801108a16969b420b341e2deaa6ba62deb116c Signed-off-by: Eren ATAS <eatas.contractor@libertyglobal.com>
This commit is contained in:
parent
c5fac510f2
commit
15ee9899b8
@ -13,6 +13,7 @@
|
||||
# under the License.
|
||||
|
||||
import logging
|
||||
import sys
|
||||
|
||||
import xml.etree.ElementTree as XML
|
||||
|
||||
@ -21,6 +22,8 @@ from jenkins_jobs.errors import JenkinsJobsException
|
||||
from jenkins_jobs.errors import MissingAttributeError
|
||||
from jenkins_jobs.modules import hudson_model
|
||||
|
||||
import pkg_resources
|
||||
|
||||
|
||||
def build_trends_publisher(plugin_name, xml_element, data):
|
||||
"""Helper to create various trend publishers.
|
||||
@ -511,7 +514,10 @@ def trigger_get_parameter_order(registry, plugin):
|
||||
return None
|
||||
|
||||
|
||||
def trigger_project(tconfigs, project_def, param_order=None):
|
||||
def trigger_project(tconfigs, project_def, registry, param_order=None):
|
||||
|
||||
info = registry.get_plugin_info("parameterized-trigger")
|
||||
plugin_version = pkg_resources.parse_version(info.get("version", str(sys.maxsize)))
|
||||
|
||||
logger = logging.getLogger("%s:trigger_project" % __name__)
|
||||
pt_prefix = "hudson.plugins.parameterizedtrigger."
|
||||
@ -548,6 +554,12 @@ def trigger_project(tconfigs, project_def, param_order=None):
|
||||
("property-file", "propertiesFile", None),
|
||||
("fail-on-missing", "failTriggerOnMissing", False),
|
||||
]
|
||||
|
||||
if plugin_version >= pkg_resources.parse_version("2.35.2"):
|
||||
property_file_mapping.append(
|
||||
("property-multiline", "textParamValueOnNewLine", False)
|
||||
)
|
||||
|
||||
convert_mapping_to_xml(
|
||||
params, project_def, property_file_mapping, fail_required=True
|
||||
)
|
||||
|
@ -527,6 +527,12 @@ def trigger_parameterized_builds(registry, xml_parent, data):
|
||||
if any of the property files are not found in the workspace.
|
||||
Only valid when 'property-file' is specified.
|
||||
(default 'False')
|
||||
:arg bool property-multiline: When enabled properties containing
|
||||
newline character(s) are propagated as TextParameterValue which is
|
||||
a specialized StringParameterValue commonly used for handling
|
||||
multi-line strings in Jenkins. When disabled (default)
|
||||
all properties are propagated as StringParameterValue. (default
|
||||
'False') (>=2.35.2)
|
||||
:arg bool trigger-from-child-projects: Trigger build from child projects.
|
||||
Used for matrix projects. (default 'False')
|
||||
:arg bool use-matrix-child-files: Use files in workspaces of child
|
||||
@ -568,7 +574,7 @@ def trigger_parameterized_builds(registry, xml_parent, data):
|
||||
tconfig = XML.SubElement(configs, pt_prefix + "BuildTriggerConfig")
|
||||
tconfigs = XML.SubElement(tconfig, "configs")
|
||||
|
||||
helpers.trigger_project(tconfigs, project_def, param_order)
|
||||
helpers.trigger_project(tconfigs, project_def, registry, param_order)
|
||||
|
||||
if not list(tconfigs):
|
||||
# no child parameter tags added
|
||||
@ -2387,7 +2393,7 @@ def pipeline(registry, xml_parent, data):
|
||||
|
||||
configs = XML.SubElement(pippub, "configs")
|
||||
|
||||
helpers.trigger_project(configs, data, param_order)
|
||||
helpers.trigger_project(configs, data, registry, param_order)
|
||||
|
||||
XML.SubElement(pippub, "downstreamProjectNames").text = projects
|
||||
|
||||
|
3
tests/publishers/fixtures/pipeline003.plugins_info.yaml
Normal file
3
tests/publishers/fixtures/pipeline003.plugins_info.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
- longName: 'Parameterized Trigger'
|
||||
shortName: 'parameterized-trigger'
|
||||
version: "2.34"
|
@ -11,6 +11,7 @@
|
||||
<hudson.plugins.parameterizedtrigger.FileBuildParameters>
|
||||
<propertiesFile>version.prop</propertiesFile>
|
||||
<failTriggerOnMissing>false</failTriggerOnMissing>
|
||||
<textParamValueOnNewLine>false</textParamValueOnNewLine>
|
||||
</hudson.plugins.parameterizedtrigger.FileBuildParameters>
|
||||
<hudson.plugins.parameterizedtrigger.CurrentBuildParameters/>
|
||||
</configs>
|
||||
@ -28,6 +29,7 @@
|
||||
<hudson.plugins.parameterizedtrigger.FileBuildParameters>
|
||||
<propertiesFile>version.prop</propertiesFile>
|
||||
<failTriggerOnMissing>false</failTriggerOnMissing>
|
||||
<textParamValueOnNewLine>false</textParamValueOnNewLine>
|
||||
</hudson.plugins.parameterizedtrigger.FileBuildParameters>
|
||||
</configs>
|
||||
<projects>yet_another_job</projects>
|
||||
|
@ -27,6 +27,7 @@ bar=foo
|
||||
<hudson.plugins.parameterizedtrigger.FileBuildParameters>
|
||||
<propertiesFile>version.prop</propertiesFile>
|
||||
<failTriggerOnMissing>true</failTriggerOnMissing>
|
||||
<textParamValueOnNewLine>true</textParamValueOnNewLine>
|
||||
</hudson.plugins.parameterizedtrigger.FileBuildParameters>
|
||||
</configs>
|
||||
<projects>other_job1, other_job2</projects>
|
||||
|
@ -12,6 +12,7 @@ publishers:
|
||||
git-revision: true
|
||||
property-file: version.prop
|
||||
fail-on-missing: true
|
||||
property-multiline: true
|
||||
- project: yet_another_job
|
||||
predefined-parameters: foo=bar
|
||||
git-revision:
|
||||
|
@ -0,0 +1,3 @@
|
||||
- longName: 'Parameterized Trigger'
|
||||
shortName: 'parameterized-trigger'
|
||||
version: "2.34"
|
@ -0,0 +1,3 @@
|
||||
- longName: 'Parameterized Trigger'
|
||||
shortName: 'parameterized-trigger'
|
||||
version: "2.34"
|
@ -8,6 +8,7 @@
|
||||
<hudson.plugins.parameterizedtrigger.FileBuildParameters>
|
||||
<propertiesFile>version.prop</propertiesFile>
|
||||
<failTriggerOnMissing>false</failTriggerOnMissing>
|
||||
<textParamValueOnNewLine>false</textParamValueOnNewLine>
|
||||
<useMatrixChild>true</useMatrixChild>
|
||||
<combinationFilter>FOO && BAR</combinationFilter>
|
||||
<onlyExactRuns>true</onlyExactRuns>
|
||||
|
@ -0,0 +1,3 @@
|
||||
- longName: 'Parameterized Trigger'
|
||||
shortName: 'parameterized-trigger'
|
||||
version: "2.34"
|
@ -0,0 +1,3 @@
|
||||
- longName: 'Parameterized Trigger'
|
||||
shortName: 'parameterized-trigger'
|
||||
version: "2.34"
|
@ -0,0 +1,3 @@
|
||||
- longName: 'Parameterized Trigger'
|
||||
shortName: 'parameterized-trigger'
|
||||
version: "2.34"
|
Loading…
Reference in New Issue
Block a user