summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2019-08-15 19:00:57 +0000
committerGerrit Code Review <review@openstack.org>2019-08-15 19:00:57 +0000
commitead185134d8aa5d3d0974207356de6c4fdb2e6e8 (patch)
tree33e3a3e584bf2cda1f03c132f22a4e9126b6fce5
parenta1eb48e9397d054e57a06d9f93adf06d4d6784f6 (diff)
parent5117d87e8c7b9272f1ac5ef59f2f05afc32c9715 (diff)
downloadpython-jenkins-job-builder-ead185134d8aa5d3d0974207356de6c4fdb2e6e8.tar.gz
python-jenkins-job-builder-ead185134d8aa5d3d0974207356de6c4fdb2e6e8.tar.xz
python-jenkins-job-builder-ead185134d8aa5d3d0974207356de6c4fdb2e6e8.zip
Merge "Add support for two new plugins, and a new version of one"
-rw-r--r--jenkins_jobs/modules/project_matrix.py11
-rw-r--r--jenkins_jobs/modules/properties.py12
-rw-r--r--jenkins_jobs/modules/publishers.py22
-rw-r--r--jenkins_jobs/modules/scm.py109
-rw-r--r--tests/general/fixtures/matrix-axis-p4-strategy-file.xml14
-rw-r--r--tests/general/fixtures/matrix-axis-p4-strategy-file.yaml4
-rw-r--r--tests/properties/fixtures/priority_sorter003.plugins_info.yaml3
-rw-r--r--tests/properties/fixtures/priority_sorter003.xml9
-rw-r--r--tests/properties/fixtures/priority_sorter003.yaml3
-rw-r--r--tests/publishers/fixtures/influxdb-full.xml12
-rw-r--r--tests/publishers/fixtures/influxdb-full.yaml7
-rw-r--r--tests/publishers/fixtures/influxdb-minimal.xml12
-rw-r--r--tests/publishers/fixtures/influxdb-minimal.yaml3
-rw-r--r--tests/scm/fixtures/p4-001.xml25
-rw-r--r--tests/scm/fixtures/p4-001.yaml10
-rw-r--r--tests/scm/fixtures/p4-002.xml38
-rw-r--r--tests/scm/fixtures/p4-002.yaml21
-rw-r--r--tests/scm/fixtures/p4-003.xml41
-rw-r--r--tests/scm/fixtures/p4-003.yaml11
19 files changed, 366 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.
diff --git a/tests/general/fixtures/matrix-axis-p4-strategy-file.xml b/tests/general/fixtures/matrix-axis-p4-strategy-file.xml
new file mode 100644
index 00000000..de485efa
--- /dev/null
+++ b/tests/general/fixtures/matrix-axis-p4-strategy-file.xml
@@ -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>
diff --git a/tests/general/fixtures/matrix-axis-p4-strategy-file.yaml b/tests/general/fixtures/matrix-axis-p4-strategy-file.yaml
new file mode 100644
index 00000000..3fd84a21
--- /dev/null
+++ b/tests/general/fixtures/matrix-axis-p4-strategy-file.yaml
@@ -0,0 +1,4 @@
+project-type: matrix
+p4-strategy:
+ sequential: false
+ build-parent: false
diff --git a/tests/properties/fixtures/priority_sorter003.plugins_info.yaml b/tests/properties/fixtures/priority_sorter003.plugins_info.yaml
new file mode 100644
index 00000000..2d581816
--- /dev/null
+++ b/tests/properties/fixtures/priority_sorter003.plugins_info.yaml
@@ -0,0 +1,3 @@
+- longName: 'Jenkins Priority Sorter Plugin'
+ shortName: 'PrioritySorter'
+ version: '3.0'
diff --git a/tests/properties/fixtures/priority_sorter003.xml b/tests/properties/fixtures/priority_sorter003.xml
new file mode 100644
index 00000000..876ff7b5
--- /dev/null
+++ b/tests/properties/fixtures/priority_sorter003.xml
@@ -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>
diff --git a/tests/properties/fixtures/priority_sorter003.yaml b/tests/properties/fixtures/priority_sorter003.yaml
new file mode 100644
index 00000000..9153de67
--- /dev/null
+++ b/tests/properties/fixtures/priority_sorter003.yaml
@@ -0,0 +1,3 @@
+properties:
+ - priority-sorter:
+ priority: Priority 3
diff --git a/tests/publishers/fixtures/influxdb-full.xml b/tests/publishers/fixtures/influxdb-full.xml
new file mode 100644
index 00000000..b08e0bfd
--- /dev/null
+++ b/tests/publishers/fixtures/influxdb-full.xml
@@ -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>
diff --git a/tests/publishers/fixtures/influxdb-full.yaml b/tests/publishers/fixtures/influxdb-full.yaml
new file mode 100644
index 00000000..219c5d47
--- /dev/null
+++ b/tests/publishers/fixtures/influxdb-full.yaml
@@ -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
diff --git a/tests/publishers/fixtures/influxdb-minimal.xml b/tests/publishers/fixtures/influxdb-minimal.xml
new file mode 100644
index 00000000..1ea806f8
--- /dev/null
+++ b/tests/publishers/fixtures/influxdb-minimal.xml
@@ -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>
diff --git a/tests/publishers/fixtures/influxdb-minimal.yaml b/tests/publishers/fixtures/influxdb-minimal.yaml
new file mode 100644
index 00000000..fd5871c0
--- /dev/null
+++ b/tests/publishers/fixtures/influxdb-minimal.yaml
@@ -0,0 +1,3 @@
+publishers:
+ - influx-db:
+ selected-target: selectedtarget
diff --git a/tests/scm/fixtures/p4-001.xml b/tests/scm/fixtures/p4-001.xml
new file mode 100644
index 00000000..30620d74
--- /dev/null
+++ b/tests/scm/fixtures/p4-001.xml
@@ -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>
diff --git a/tests/scm/fixtures/p4-001.yaml b/tests/scm/fixtures/p4-001.yaml
new file mode 100644
index 00000000..af3aa5f2
--- /dev/null
+++ b/tests/scm/fixtures/p4-001.yaml
@@ -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
diff --git a/tests/scm/fixtures/p4-002.xml b/tests/scm/fixtures/p4-002.xml
new file mode 100644
index 00000000..01de2591
--- /dev/null
+++ b/tests/scm/fixtures/p4-002.xml
@@ -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>
diff --git a/tests/scm/fixtures/p4-002.yaml b/tests/scm/fixtures/p4-002.yaml
new file mode 100644
index 00000000..5c1c32ee
--- /dev/null
+++ b/tests/scm/fixtures/p4-002.yaml
@@ -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
diff --git a/tests/scm/fixtures/p4-003.xml b/tests/scm/fixtures/p4-003.xml
new file mode 100644
index 00000000..d5d58d50
--- /dev/null
+++ b/tests/scm/fixtures/p4-003.xml
@@ -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>
diff --git a/tests/scm/fixtures/p4-003.yaml b/tests/scm/fixtures/p4-003.yaml
new file mode 100644
index 00000000..cfefeb08
--- /dev/null
+++ b/tests/scm/fixtures/p4-003.yaml
@@ -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