diff options
Diffstat (limited to 'jenkins_jobs')
-rw-r--r-- | jenkins_jobs/modules/project_matrix.py | 11 | ||||
-rw-r--r-- | jenkins_jobs/modules/properties.py | 12 | ||||
-rw-r--r-- | jenkins_jobs/modules/publishers.py | 22 | ||||
-rw-r--r-- | jenkins_jobs/modules/scm.py | 109 |
4 files changed, 153 insertions, 1 deletions
diff --git a/jenkins_jobs/modules/project_matrix.py b/jenkins_jobs/modules/project_matrix.py index a96b7f00..13c67721 100644 --- a/jenkins_jobs/modules/project_matrix.py +++ b/jenkins_jobs/modules/project_matrix.py @@ -130,6 +130,8 @@ class Matrix(jenkins_jobs.modules.base.Base): 'hudson.matrix.DefaultMatrixExecutionStrategyImpl', 'yaml-strategy': 'org.jenkinsci.plugins.yamlaxis.YamlMatrixExecutionStrategy', + 'p4-strategy': + 'org.jenkinsci.plugins.p4.matrix.MatrixOptions' } def root_xml(self, data): @@ -202,6 +204,15 @@ class Matrix(jenkins_jobs.modules.base.Base): 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') for axis_ in data.get('axes', []): axis = axis_['axis'] diff --git a/jenkins_jobs/modules/properties.py b/jenkins_jobs/modules/properties.py index 22192e12..2907ec4f 100644 --- a/jenkins_jobs/modules/properties.py +++ b/jenkins_jobs/modules/properties.py @@ -580,7 +580,17 @@ def priority_sorter(registry, xml_parent, data): plugin_info = registry.get_plugin_info('PrioritySorter') 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, 'jenkins.advancedqueue.priority.' 'strategy.PriorityJobProperty') diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 29c3ea4e..c165d7d4 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -40,6 +40,28 @@ from jenkins_jobs.modules import hudson_model 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): """yaml: allure diff --git a/jenkins_jobs/modules/scm.py b/jenkins_jobs/modules/scm.py index 6c68dc15..baa4f94c 100644 --- a/jenkins_jobs/modules/scm.py +++ b/jenkins_jobs/modules/scm.py @@ -45,6 +45,115 @@ import jenkins_jobs.modules.base 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): r"""yaml: git Specifies the git SCM repository for this job. |