Add support for parameters in pipeline publisher.

Change-Id: Ie36d7c6a9daab17adf93586f79b92be0ed267c35
This commit is contained in:
Joao Vale 2014-01-09 16:47:19 +00:00
parent c39c5de446
commit c17b504e8d
5 changed files with 57 additions and 6 deletions

View File

@ -1160,12 +1160,16 @@ def pipeline(parser, xml_parent, data):
Requires the Jenkins `Build Pipeline Plugin.
<https://wiki.jenkins-ci.org/display/JENKINS/Build+Pipeline+Plugin>`_
:Parameter: the name of the downstream project
:arg str project: the name of the downstream project
:arg str predefined-parameters: parameters to pass to the other
job (optional)
:arg bool current-parameters: Whether to include the parameters passed
to the current build to the triggered job (optional)
Example::
Example:
.. literalinclude:: ../../tests/publishers/fixtures/pipeline002.yaml
publishers:
- pipeline: deploy
You can build pipeline jobs that are re-usable in different pipelines by
using a :ref:`job-template` to define the pipeline jobs,
@ -1175,11 +1179,27 @@ def pipeline(parser, xml_parent, data):
See 'samples/pipeline.yaml' for an example pipeline implementation.
"""
if data != '':
if 'project' in data and data['project'] != '':
pippub = XML.SubElement(xml_parent,
'au.com.centrumsystems.hudson.plugin.'
'buildpipeline.trigger.BuildPipelineTrigger')
XML.SubElement(pippub, 'downstreamProjectNames').text = data
configs = XML.SubElement(pippub, 'configs')
if 'predefined-parameters' in data:
params = XML.SubElement(configs,
'hudson.plugins.parameterizedtrigger.'
'PredefinedBuildParameters')
properties = XML.SubElement(params, 'properties')
properties.text = data['predefined-parameters']
if ('current-parameters' in data
and data['current-parameters']):
XML.SubElement(configs,
'hudson.plugins.parameterizedtrigger.'
'CurrentBuildParameters')
XML.SubElement(pippub, 'downstreamProjectNames').text = data['project']
def email(parser, xml_parent, data):

View File

@ -0,0 +1,9 @@
<?xml version="1.0" ?>
<project>
<publishers>
<au.com.centrumsystems.hudson.plugin.buildpipeline.trigger.BuildPipelineTrigger>
<configs/>
<downstreamProjectNames>test_project</downstreamProjectNames>
</au.com.centrumsystems.hudson.plugin.buildpipeline.trigger.BuildPipelineTrigger>
</publishers>
</project>

View File

@ -0,0 +1,3 @@
publishers:
- pipeline:
project: test_project

View File

@ -0,0 +1,14 @@
<?xml version="1.0" ?>
<project>
<publishers>
<au.com.centrumsystems.hudson.plugin.buildpipeline.trigger.BuildPipelineTrigger>
<configs>
<hudson.plugins.parameterizedtrigger.PredefinedBuildParameters>
<properties>foo=bar</properties>
</hudson.plugins.parameterizedtrigger.PredefinedBuildParameters>
<hudson.plugins.parameterizedtrigger.CurrentBuildParameters/>
</configs>
<downstreamProjectNames>test_project</downstreamProjectNames>
</au.com.centrumsystems.hudson.plugin.buildpipeline.trigger.BuildPipelineTrigger>
</publishers>
</project>

View File

@ -0,0 +1,5 @@
publishers:
- pipeline:
project: test_project
current-parameters: true
predefined-parameters: foo=bar