Merge "Add Dimensions SCM support"

This commit is contained in:
Jenkins 2017-02-11 14:22:15 +00:00 committed by Gerrit Code Review
commit 4960f92ad3
5 changed files with 181 additions and 0 deletions

View File

@ -1256,6 +1256,109 @@ def url(registry, xml_parent, data):
data.get('clear-workspace', False)).lower()
def dimensions(registry, xml_parent, data):
"""yaml: dimensions
Specifies the Dimensions SCM repository for this job.
Requires Jenkins :jenkins-wiki:`Dimensions Plugin <Dimensions+Plugin>`.
:arg str project: Project name of format PRODUCT_ID:PROJECT_NAME (required)
:arg str permissions: Default Permissions for updated files
(default: DEFAULT)
:Permissions:
* **DEFAULT**
* **READONLY**
* **WRITABLE**
:arg str eol: End of line (default: DEFAULT)
:End of line:
* **DEFAULT**
* **UNIX**
* **WINDOWS**
* **UNCHANGED**
:arg list folders: Folders to monitor (default /)
:arg list exclude: Paths to exclude from monitor
:arg str username: Repository username for this job
:arg str password: Repository password for this job
:arg str server: Dimensions server for this job
:arg str database: Dimensions database for this job.
Format must be database@dsn
:arg bool update: Use update (default false)
:arg bool clear-workspace: Clear workspace prior to build (default false)
:arg bool force-build: Force build even if the repository SCM checkout
operation fails (default false)
:arg bool overwrite-modified: Overwrite files in worspace from
repository files (default false)
:arg bool expand-vars: Expand substitution variables (default false)
:arg bool no-metadata: Checkout files with no metadata (default false)
:arg bool maintain-timestamp: Maintain file timestamp from Dimensions
(default false)
:arg bool slave-checkout: Force slave based checkout (default false)
:arg str timezone: Server timezone
:arg str web-url: Dimensions Web URL
Examples:
.. literalinclude:: /../../tests/scm/fixtures/dimensions-minimal.yaml
:language: yaml
.. literalinclude:: /../../tests/scm/fixtures/dimensions-full.yaml
:language: yaml
"""
scm = XML.SubElement(
xml_parent,
'scm', {'class': 'hudson.plugins.dimensionsscm.DimensionsSCM'})
# List to check against for valid permission
perm = ['DEFAULT', 'READONLY', 'WRITABLE']
# List to check against for valid end of line
eol = ['DEFAULT', 'UNIX', 'WINDOWS', 'UNCHANGED']
mapping = [
# option, xml name, default value (text), attributes (hard coded)
('project', 'project', None),
('permissions', 'permissions', 'DEFAULT', perm),
('eol', 'eol', 'DEFAULT', eol),
('update', 'canJobUpdate', False),
('clear-workspace', 'canJobDelete', False),
('force-build', 'canJobForce', False),
('overwrite-modified', 'canJobRevert', False),
('expand-vars', 'canJobExpand', False),
('no-metadata', 'canJobNoMetadata', False),
('maintain-timestamp', 'canJobNoTouch', False),
('slave-checkout', 'forceAsSlave', False),
]
convert_mapping_to_xml(scm, data, mapping, fail_required=True)
# Folders to monitor. Default '/'
folders = XML.SubElement(scm, 'folders')
if 'folders' in data:
for folder in data['folders']:
XML.SubElement(folders, 'string').text = folder
else:
XML.SubElement(folders, 'string').text = '/'
# Excluded paths
exclude = XML.SubElement(scm, 'pathsToExclude')
if 'exclude' in data:
for exc in data['exclude']:
XML.SubElement(exclude, 'string').text = exc
optional_mapping = [
# option, xml name, default value (text), attributes (hard coded)
('username', 'jobUserName', None),
('password', 'jobPasswd', None),
('server', 'jobServer', None),
('database', 'jobDatabase', None),
('timezone', 'jobTimeZone', None),
('web-url', 'jobWebUrl', None),
]
convert_mapping_to_xml(scm, data, optional_mapping, fail_required=False)
class SCM(jenkins_jobs.modules.base.Base):
sequence = 30

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<scm class="hudson.plugins.dimensionsscm.DimensionsSCM">
<project>myProduct:myProject</project>
<permissions>WRITABLE</permissions>
<eol>UNIX</eol>
<canJobUpdate>true</canJobUpdate>
<canJobDelete>true</canJobDelete>
<canJobForce>true</canJobForce>
<canJobRevert>true</canJobRevert>
<canJobExpand>true</canJobExpand>
<canJobNoMetadata>true</canJobNoMetadata>
<canJobNoTouch>true</canJobNoTouch>
<forceAsSlave>true</forceAsSlave>
<folders>
<string>src</string>
<string>test</string>
</folders>
<pathsToExclude>
<string>excluded_dir</string>
<string>excluded_other_dir</string>
</pathsToExclude>
<jobUserName>johnd</jobUserName>
<jobPasswd>passw0rd</jobPasswd>
<jobServer>my.dmscm.server:1234</jobServer>
<jobDatabase>myDatabase@myDsn</jobDatabase>
<jobTimeZone>Europe/Berlin</jobTimeZone>
<jobWebUrl>https://my.dmscm.weburl</jobWebUrl>
</scm>
</project>

View File

@ -0,0 +1,25 @@
scm:
- dimensions:
project: myProduct:myProject
permissions: WRITABLE
eol: UNIX
folders:
- src
- test
exclude:
- excluded_dir
- excluded_other_dir
username: johnd
password: passw0rd
server: my.dmscm.server:1234
database: myDatabase@myDsn
update: true
clear-workspace: true
force-build: true
overwrite-modified: true
expand-vars: true
no-metadata: true
maintain-timestamp: true
slave-checkout: true
timezone: Europe/Berlin
web-url: https://my.dmscm.weburl

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<scm class="hudson.plugins.dimensionsscm.DimensionsSCM">
<project>myProduct:myProject</project>
<permissions>DEFAULT</permissions>
<eol>DEFAULT</eol>
<canJobUpdate>false</canJobUpdate>
<canJobDelete>false</canJobDelete>
<canJobForce>false</canJobForce>
<canJobRevert>false</canJobRevert>
<canJobExpand>false</canJobExpand>
<canJobNoMetadata>false</canJobNoMetadata>
<canJobNoTouch>false</canJobNoTouch>
<forceAsSlave>false</forceAsSlave>
<folders>
<string>/</string>
</folders>
<pathsToExclude/>
</scm>
</project>

View File

@ -0,0 +1,3 @@
scm:
- dimensions:
project: myProduct:myProject