Update Delivery Pipeline plugin to use convert xml

- Add plugin="delivery-pipeline-plugin" attribute
- Rename test files to be more descriptive

Change-Id: I9db5315e425da6bd5c69b533c79d6d5ab4ed1e70
Signed-off-by: Kien Ha <kienha9922@gmail.com>
This commit is contained in:
Kien Ha 2016-07-25 15:09:21 -04:00
parent a88104422e
commit 673927e5e9
10 changed files with 40 additions and 22 deletions

View File

@ -39,6 +39,7 @@ from jenkins_jobs.errors import InvalidAttributeError
from jenkins_jobs.errors import JenkinsJobsException
from jenkins_jobs.errors import MissingAttributeError
import jenkins_jobs.modules.base
from jenkins_jobs.modules.helpers import convert_mapping_to_xml
def builds_chain_fingerprinter(parser, xml_parent, data):
@ -632,20 +633,28 @@ def delivery_pipeline(parser, xml_parent, data):
:arg str description: task description template for this job
(default '')
Example:
Minimal Example:
.. literalinclude::
/../../tests/properties/fixtures/delivery-pipeline1.yaml
/../../tests/properties/fixtures/delivery-pipeline-minimal.yaml
:language: yaml
Full Example:
.. literalinclude::
/../../tests/properties/fixtures/delivery-pipeline-full.yaml
:language: yaml
"""
pipeline = XML.SubElement(xml_parent,
'se.diabol.jenkins.pipeline.'
'PipelineProperty')
XML.SubElement(pipeline, 'stageName').text = data.get('stage', '')
XML.SubElement(pipeline, 'taskName').text = data.get('task', '')
XML.SubElement(pipeline, 'descriptionTemplate').text = str(
data.get('description', ''))
pipeline = XML.SubElement(
xml_parent, 'se.diabol.jenkins.pipeline.PipelineProperty')
pipeline.set('plugin', 'delivery-pipeline-plugin')
mapping = [
('stage', 'stageName', ''),
('task', 'taskName', ''),
('description', 'descriptionTemplate', ''),
]
convert_mapping_to_xml(pipeline, data, mapping, fail_required=True)
def zeromq_event(parser, xml_parent, data):

View File

@ -1521,18 +1521,27 @@ def delivery_pipeline(parser, xml_parent, data):
:arg bool set-display-name: Set the generated version as the display name
for the build (default false)
Example:
Minimal Example:
.. literalinclude:: /../../tests/wrappers/fixtures/delivery-pipeline1.yaml
.. literalinclude::
/../../tests/wrappers/fixtures/delivery-pipeline-minimal.yaml
:language: yaml
Full Example:
.. literalinclude::
/../../tests/wrappers/fixtures/delivery-pipeline-full.yaml
:language: yaml
"""
pvc = XML.SubElement(xml_parent,
'se.diabol.jenkins.pipeline.'
'PipelineVersionContributor')
XML.SubElement(pvc, 'versionTemplate').text = data.get(
'version-template', '')
XML.SubElement(pvc, 'updateDisplayName').text = str(data.get(
'set-display-name', False)).lower()
pvc = XML.SubElement(
xml_parent, 'se.diabol.jenkins.pipeline.PipelineVersionContributor')
pvc.set('plugin', 'delivery-pipeline-plugin')
mapping = [
('version-template', 'versionTemplate', ''),
('set-display-name', 'updateDisplayName', False),
]
convert_mapping_to_xml(pvc, data, mapping, fail_required=True)
def matrix_tie_parent(parser, xml_parent, data):

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<properties>
<se.diabol.jenkins.pipeline.PipelineProperty>
<se.diabol.jenkins.pipeline.PipelineProperty plugin="delivery-pipeline-plugin">
<stageName>Stage</stageName>
<taskName>Task</taskName>
<descriptionTemplate>Task-Description</descriptionTemplate>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<properties>
<se.diabol.jenkins.pipeline.PipelineProperty>
<se.diabol.jenkins.pipeline.PipelineProperty plugin="delivery-pipeline-plugin">
<stageName/>
<taskName/>
<descriptionTemplate/>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<buildWrappers>
<se.diabol.jenkins.pipeline.PipelineVersionContributor>
<se.diabol.jenkins.pipeline.PipelineVersionContributor plugin="delivery-pipeline-plugin">
<versionTemplate>1.0.0-${BUILD_NUMBER}</versionTemplate>
<updateDisplayName>true</updateDisplayName>
</se.diabol.jenkins.pipeline.PipelineVersionContributor>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<buildWrappers>
<se.diabol.jenkins.pipeline.PipelineVersionContributor>
<se.diabol.jenkins.pipeline.PipelineVersionContributor plugin="delivery-pipeline-plugin">
<versionTemplate/>
<updateDisplayName>false</updateDisplayName>
</se.diabol.jenkins.pipeline.PipelineVersionContributor>