Support version 2.0 and greater of the Priority Sorter Plugin

The Priority Sorter Plugin changed the xml specification after 2.0. The commit
reflects that change but also keeps support for version 1.0.

References:
[1] https://storyboard.openstack.org/#!/story/2001534
[2] https://wiki.jenkins.io/display/JENKINS/Priority+Sorter+Plugin

Change-Id: I2f861265dfa64cde930c6a8e66c967bf1e6fc831
Closes-Bug: 2001534
This commit is contained in:
John Fragoulis 2018-02-14 12:13:47 +02:00
parent 9663d32c60
commit 5e5baa114f
7 changed files with 40 additions and 6 deletions

View File

@ -497,17 +497,33 @@ def priority_sorter(registry, xml_parent, data):
<Priority+Sorter+Plugin>`.
:arg int priority: Priority of the job. Higher value means higher
priority, with 100 as the standard priority. (required)
priority, with 3 as the default priority. (required)
Example:
.. literalinclude:: /../../tests/properties/fixtures/priority_sorter.yaml
.. literalinclude::
/../../tests/properties/fixtures/priority_sorter002.yaml
:language: yaml
"""
priority_sorter_tag = XML.SubElement(xml_parent,
'hudson.queueSorter.'
'PrioritySorterJobProperty')
mapping = [('priority', 'priority', None)]
plugin_info = registry.get_plugin_info('Priority Sorter Plugin')
version = pkg_resources.parse_version(plugin_info.get('version', '0'))
if version >= pkg_resources.parse_version("2.0"):
priority_sorter_tag = XML.SubElement(xml_parent,
'jenkins.advancedqueue.priority.'
'strategy.PriorityJobProperty')
mapping = [
('use', 'useJobPriority', True),
('priority', 'priority', None)
]
else:
priority_sorter_tag = XML.SubElement(xml_parent,
'hudson.queueSorter.'
'PrioritySorterJobProperty')
mapping = [('priority', 'priority', None)]
helpers.convert_mapping_to_xml(
priority_sorter_tag, data, mapping, fail_required=True)

View File

@ -0,0 +1,3 @@
- longName: 'Priority Sorter Plugin'
shortName: 'PrioritySorter'
version: '1.0'

View File

@ -0,0 +1,3 @@
- longName: 'Priority Sorter Plugin'
shortName: 'PrioritySorter'
version: '2.0'

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<properties>
<jenkins.advancedqueue.priority.strategy.PriorityJobProperty>
<useJobPriority>true</useJobPriority>
<priority>3</priority>
</jenkins.advancedqueue.priority.strategy.PriorityJobProperty>
</properties>
</project>

View File

@ -0,0 +1,3 @@
properties:
- priority-sorter:
priority: 3