Update MongoDB plugin

- Update to use convert xml
- Update doc options to have default values
- Rename test files to be more descriptive

Change-Id: I83ada14df074805333eb50d746a0bc90fd7b5619
Signed-off-by: Kien Ha <kienha9922@gmail.com>
This commit is contained in:
Kien Ha 2016-07-14 18:51:10 -04:00
parent d6add35e72
commit 739f90a653
5 changed files with 19 additions and 17 deletions

View File

@ -37,6 +37,7 @@ from jenkins_jobs.modules.helpers import artifactory_env_vars_patterns
from jenkins_jobs.modules.helpers import artifactory_optional_props from jenkins_jobs.modules.helpers import artifactory_optional_props
from jenkins_jobs.modules.helpers import artifactory_repository from jenkins_jobs.modules.helpers import artifactory_repository
from jenkins_jobs.modules.helpers import config_file_provider_builder from jenkins_jobs.modules.helpers import config_file_provider_builder
from jenkins_jobs.modules.helpers import convert_mapping_to_xml
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -1473,33 +1474,34 @@ def mongo_db(parser, xml_parent, data):
Initalizes a MongoDB database while running the build. Initalizes a MongoDB database while running the build.
Requires the Jenkins :jenkins-wiki:`MongoDB plugin <MongoDB+Plugin>`. Requires the Jenkins :jenkins-wiki:`MongoDB plugin <MongoDB+Plugin>`.
:arg str name: The name of the MongoDB install to use :arg str name: The name of the MongoDB install to use (required)
:arg str data-directory: Data directory for the server (optional) :arg str data-directory: Data directory for the server (default '')
:arg int port: Port for the server (optional) :arg int port: Port for the server (default '')
:arg str startup-params: Startup parameters for the server (optional) :arg str startup-params: Startup parameters for the server (default '')
:arg int start-timeout: How long to wait for the server to start in :arg int start-timeout: How long to wait for the server to start in
milliseconds. 0 means no timeout. (default '0') milliseconds. 0 means no timeout. (default 0)
Example: Full Example:
.. literalinclude:: /../../tests/wrappers/fixtures/mongo-db001.yaml .. literalinclude:: /../../tests/wrappers/fixtures/mongo-db-full.yaml
Minimal Example:
.. literalinclude:: /../../tests/wrappers/fixtures/mongo-db-minimal.yaml
""" """
mongodb = XML.SubElement(xml_parent, mongodb = XML.SubElement(xml_parent,
'org.jenkinsci.plugins.mongodb.' 'org.jenkinsci.plugins.mongodb.'
'MongoBuildWrapper') 'MongoBuildWrapper')
mongodb.set('plugin', 'mongodb') mongodb.set('plugin', 'mongodb')
if not str(data.get('name', '')): mapping = [
raise JenkinsJobsException('The mongo install name must be specified.') ('name', 'mongodbName', None),
XML.SubElement(mongodb, 'mongodbName').text = str(data.get('name', '')) ('port', 'port', ''),
XML.SubElement(mongodb, 'port').text = str(data.get('port', '')) ('data-directory', 'dbpath', ''),
XML.SubElement(mongodb, 'dbpath').text = str(data.get( ('startup-params', 'parameters', ''),
'data-directory', '')) ('start-timeout', 'startTimeout', 0),
XML.SubElement(mongodb, 'parameters').text = str(data.get( ]
'startup-params', '')) convert_mapping_to_xml(mongodb, data, mapping, fail_required=True)
XML.SubElement(mongodb, 'startTimeout').text = str(data.get(
'start-timeout', '0'))
def delivery_pipeline(parser, xml_parent, data): def delivery_pipeline(parser, xml_parent, data):