Merge "Add support for two new plugins, and a new version of one"

This commit is contained in:
Zuul 2019-08-15 19:00:57 +00:00 committed by Gerrit Code Review
commit ead185134d
19 changed files with 366 additions and 1 deletions

View File

@ -130,6 +130,8 @@ class Matrix(jenkins_jobs.modules.base.Base):
'hudson.matrix.DefaultMatrixExecutionStrategyImpl', 'hudson.matrix.DefaultMatrixExecutionStrategyImpl',
'yaml-strategy': 'yaml-strategy':
'org.jenkinsci.plugins.yamlaxis.YamlMatrixExecutionStrategy', 'org.jenkinsci.plugins.yamlaxis.YamlMatrixExecutionStrategy',
'p4-strategy':
'org.jenkinsci.plugins.p4.matrix.MatrixOptions'
} }
def root_xml(self, data): def root_xml(self, data):
@ -202,6 +204,15 @@ class Matrix(jenkins_jobs.modules.base.Base):
XML.SubElement(ex_r, 'excludeKey').text = exclude_key XML.SubElement(ex_r, 'excludeKey').text = exclude_key
elif strategy_name == 'p4-strategy':
XML.SubElement(ex_r, 'runSequentially').text = (
str(strategy.get('sequential', False)).lower()
)
XML.SubElement(ex_r, 'buildParent').text = (
str(strategy.get('build-parent', False)).lower()
)
ax_root = XML.SubElement(root, 'axes') ax_root = XML.SubElement(root, 'axes')
for axis_ in data.get('axes', []): for axis_ in data.get('axes', []):
axis = axis_['axis'] axis = axis_['axis']

View File

@ -580,7 +580,17 @@ def priority_sorter(registry, xml_parent, data):
plugin_info = registry.get_plugin_info('PrioritySorter') plugin_info = registry.get_plugin_info('PrioritySorter')
version = pkg_resources.parse_version(plugin_info.get('version', '0')) version = pkg_resources.parse_version(plugin_info.get('version', '0'))
if version >= pkg_resources.parse_version("2.0"): if version >= pkg_resources.parse_version("3.0"):
priority_sorter_tag = XML.SubElement(
xml_parent,
'jenkins.advancedqueue.jobinclusion.'
'strategy.JobInclusionJobProperty')
mapping = [
('use', 'useJobGroup', True),
('priority', 'jobGroupName', None)
]
elif version >= pkg_resources.parse_version("2.0"):
priority_sorter_tag = XML.SubElement(xml_parent, priority_sorter_tag = XML.SubElement(xml_parent,
'jenkins.advancedqueue.priority.' 'jenkins.advancedqueue.priority.'
'strategy.PriorityJobProperty') 'strategy.PriorityJobProperty')

View File

@ -40,6 +40,28 @@ from jenkins_jobs.modules import hudson_model
import jenkins_jobs.modules.helpers as helpers import jenkins_jobs.modules.helpers as helpers
def influx_db(registry, xml_parent, data):
"""yaml: influx-db
Requires the Jenkins :jenkins-wiki: `Influx DB
<Influx+DB+Plugin>`.
"""
influx_db = XML.SubElement(xml_parent,
'jenkinsci.plugins.influxdb.InfluxDbPublisher',
{'plugin': 'influx-db'})
mapping = [
('selected-target', 'selectedTarget', ''),
('custom-project-name', 'customProjectName', ''),
('custom-prefix', 'customPrefix', ''),
('jenkins-env-parameter-field', 'jenkinsEnvParameterField', ''),
('jenkins-env-parameter-tag', 'jenkinsEnvParameterTag', '')
]
helpers.convert_mapping_to_xml(
influx_db, data, mapping, fail_required=True)
def allure(registry, xml_parent, data): def allure(registry, xml_parent, data):
"""yaml: allure """yaml: allure

View File

@ -45,6 +45,115 @@ import jenkins_jobs.modules.base
import jenkins_jobs.modules.helpers as helpers import jenkins_jobs.modules.helpers as helpers
def p4(registry, xml_parent, data):
r"""yaml: p4
Specifies the Perforce (P4) repository for this job
Requires the Jenkins :jenkins-wiki:`P4 Plugin <P4+Plugin>`.
"""
scm = XML.SubElement(xml_parent, 'scm',
{'class': 'org.jenkinsci.plugins.p4.PerforceScm',
'plugin': 'p4'})
XML.SubElement(scm, 'credential').text = data.get('credential')
p4_construct_workspace(scm, data)
p4_construct_populate(scm, data)
def p4_construct_workspace(xml_parent, data):
workspace = None
workspace_mapping = [
('workspace-charset', 'charset', 'none'),
('workspace-pin-host', 'pinHost', False),
('workspace-name', 'name', ''),
('workspace-cleanup', 'cleanup', None)
]
if data.get('workspace-type') == 'Static':
workspace = XML.SubElement(xml_parent, 'workspace',
{'class':
'org.jenkinsci.plugins.p4.workspace.StaticWorkspaceImpl'})
elif data.get('workspace-type') == 'Manual':
workspace = XML.SubElement(xml_parent, 'workspace',
{'class':
'org.jenkinsci.plugins.p4.workspace.ManualWorkspaceImpl'})
spec = XML.SubElement(workspace, 'spec')
spec_mapping = [
('spec-allwrite', 'allwrite', False),
('spec-clobber', 'clobber', False),
('spec-compress', 'compress', False),
('spec-locked', 'locked', False),
('spec-modtime', 'modtime', False),
('spec-rmdir', 'rmdir', False),
('spec-line', 'line', ''),
('spec-view', 'view', ''),
('spec-type', 'type', ''),
('spec-backup', 'backup', False),
('spec-stream-name', 'streamName', '')
]
helpers.convert_mapping_to_xml(
spec, data, spec_mapping, fail_required=False)
if 'view-mask' in data.keys():
filter_node = XML.SubElement(xml_parent, 'filter')
view_mask = XML.SubElement(filter_node,
'org.jenkinsci.plugins.p4.filters.FilterViewMaskImpl')
view_mask_mapping = [
('view-mask', 'viewMask', None)
]
helpers.convert_mapping_to_xml(
view_mask, data, view_mask_mapping, fail_required=False)
helpers.convert_mapping_to_xml(
workspace, data, workspace_mapping, fail_required=False)
def p4_construct_populate(xml_parent, data):
populate = None
populate_mapping = [
('populate-have-list', 'have', False),
('populate-force-sync', 'force', False),
('populate-modtime', 'modtime', False),
('populate-quiet', 'quiet', False),
('populate-label', 'pin', None),
('populate-revert', 'revert', None),
('populate-replace', 'replace', None),
('populate-delete', 'delete', None),
('populate-tidy', 'tidy', None)
]
parallel_mapping = [
('parallel-enabled', 'enable', False),
('parallel-threads', 'threads', '4'),
('parallel-minfiles', 'minfiles', '1'),
('parallel-minbytes', 'minbytes', '1024')
]
if data.get('populate-type') == 'SyncOnly':
populate = XML.SubElement(xml_parent, 'populate',
{'class': 'org.jenkinsci.plugins.p4.populate.SyncOnlyImpl'})
elif data.get('populate-type') == 'AutoClean':
populate = XML.SubElement(xml_parent, 'populate',
{'class': 'org.jenkinsci.plugins.p4.populate.AutoCleanImpl'})
helpers.convert_mapping_to_xml(
populate, data, populate_mapping, fail_required=False)
parallel = XML.SubElement(populate, 'parallel')
helpers.convert_mapping_to_xml(
parallel, data, parallel_mapping, fail_required=False)
def git(registry, xml_parent, data): def git(registry, xml_parent, data):
r"""yaml: git r"""yaml: git
Specifies the git SCM repository for this job. Specifies the git SCM repository for this job.

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<matrix-project>
<executionStrategy class="org.jenkinsci.plugins.p4.matrix.MatrixOptions">
<runSequentially>false</runSequentially>
<buildParent>false</buildParent>
</executionStrategy>
<axes/>
<actions/>
<keepDependencies>false</keepDependencies>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<concurrentBuild>false</concurrentBuild>
<canRoam>true</canRoam>
</matrix-project>

View File

@ -0,0 +1,4 @@
project-type: matrix
p4-strategy:
sequential: false
build-parent: false

View File

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

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<properties>
<jenkins.advancedqueue.jobinclusion.strategy.JobInclusionJobProperty>
<useJobGroup>true</useJobGroup>
<jobGroupName>Priority 3</jobGroupName>
</jenkins.advancedqueue.jobinclusion.strategy.JobInclusionJobProperty>
</properties>
</project>

View File

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

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<publishers>
<jenkinsci.plugins.influxdb.InfluxDbPublisher plugin="influx-db">
<selectedTarget>selectedtarget</selectedTarget>
<customProjectName>customprojectname</customProjectName>
<customPrefix>customprefix</customPrefix>
<jenkinsEnvParameterField>jenkinsenvparameterfield</jenkinsEnvParameterField>
<jenkinsEnvParameterTag>jenkinsenvparametertag</jenkinsEnvParameterTag>
</jenkinsci.plugins.influxdb.InfluxDbPublisher>
</publishers>
</project>

View File

@ -0,0 +1,7 @@
publishers:
- influx-db:
selected-target: selectedtarget
custom-project-name: customprojectname
custom-prefix: customprefix
jenkins-env-parameter-field: jenkinsenvparameterfield
jenkins-env-parameter-tag: jenkinsenvparametertag

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<publishers>
<jenkinsci.plugins.influxdb.InfluxDbPublisher plugin="influx-db">
<selectedTarget>selectedtarget</selectedTarget>
<customProjectName/>
<customPrefix/>
<jenkinsEnvParameterField/>
<jenkinsEnvParameterTag/>
</jenkinsci.plugins.influxdb.InfluxDbPublisher>
</publishers>
</project>

View File

@ -0,0 +1,3 @@
publishers:
- influx-db:
selected-target: selectedtarget

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<scm class="org.jenkinsci.plugins.p4.PerforceScm" plugin="p4">
<credential>credential</credential>
<workspace class="org.jenkinsci.plugins.p4.workspace.StaticWorkspaceImpl">
<charset>none</charset>
<pinHost>false</pinHost>
<name>workspacename</name>
</workspace>
<populate class="org.jenkinsci.plugins.p4.populate.SyncOnlyImpl">
<have>true</have>
<force>false</force>
<modtime>false</modtime>
<quiet>true</quiet>
<pin>populatelabel</pin>
<revert>false</revert>
<parallel>
<enable>false</enable>
<threads>4</threads>
<minfiles>1</minfiles>
<minbytes>1024</minbytes>
</parallel>
</populate>
</scm>
</project>

View File

@ -0,0 +1,10 @@
scm:
- p4:
credential: credential
workspace-type: Static
workspace-name: workspacename
populate-type: SyncOnly
populate-have-list: true
populate-quiet: true
populate-revert: false
populate-label: populatelabel

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<scm class="org.jenkinsci.plugins.p4.PerforceScm" plugin="p4">
<credential>credential</credential>
<workspace class="org.jenkinsci.plugins.p4.workspace.ManualWorkspaceImpl">
<spec>
<allwrite>true</allwrite>
<clobber>true</clobber>
<compress>true</compress>
<locked>true</locked>
<modtime>true</modtime>
<rmdir>true</rmdir>
<line>specline</line>
<view>specview</view>
<type>spectype</type>
<backup>true</backup>
<streamName>specstreamname</streamName>
</spec>
<charset>none</charset>
<pinHost>false</pinHost>
<name>workspacename</name>
</workspace>
<populate class="org.jenkinsci.plugins.p4.populate.AutoCleanImpl">
<have>true</have>
<force>false</force>
<modtime>false</modtime>
<quiet>true</quiet>
<pin>populatelabel</pin>
<revert>false</revert>
<parallel>
<enable>false</enable>
<threads>4</threads>
<minfiles>1</minfiles>
<minbytes>1024</minbytes>
</parallel>
</populate>
</scm>
</project>

View File

@ -0,0 +1,21 @@
scm:
- p4:
credential: credential
workspace-type: Manual
workspace-name: workspacename
populate-type: AutoClean
populate-have-list: True
populate-quiet: True
populate-revert: False
populate-label: populatelabel
spec-allwrite: True
spec-clobber: True
spec-compress: True
spec-locked: True
spec-modtime: True
spec-rmdir: True
spec-line: specline
spec-view: specview
spec-type: spectype
spec-backup: True
spec-stream-name: specstreamname

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<scm class="org.jenkinsci.plugins.p4.PerforceScm" plugin="p4">
<credential>credential</credential>
<workspace class="org.jenkinsci.plugins.p4.workspace.ManualWorkspaceImpl">
<spec>
<allwrite>false</allwrite>
<clobber>false</clobber>
<compress>false</compress>
<locked>false</locked>
<modtime>false</modtime>
<rmdir>false</rmdir>
<line/>
<view/>
<type/>
<backup>false</backup>
<streamName/>
</spec>
<charset>none</charset>
<pinHost>false</pinHost>
<name>workspacename</name>
</workspace>
<filter>
<org.jenkinsci.plugins.p4.filters.FilterViewMaskImpl>
<viewMask>viewmask</viewMask>
</org.jenkinsci.plugins.p4.filters.FilterViewMaskImpl>
</filter>
<populate class="org.jenkinsci.plugins.p4.populate.SyncOnlyImpl">
<have>false</have>
<force>false</force>
<modtime>false</modtime>
<quiet>false</quiet>
<parallel>
<enable>true</enable>
<threads>2</threads>
<minfiles>5</minfiles>
<minbytes>500</minbytes>
</parallel>
</populate>
</scm>
</project>

View File

@ -0,0 +1,11 @@
scm:
- p4:
credential: credential
workspace-type: Manual
workspace-name: workspacename
populate-type: SyncOnly
view-mask: viewmask
parallel-enabled: True
parallel-threads: 2
parallel-minfiles: 5
parallel-minbytes: 500