added logstash plugin support and fixed test typo
Added new test cases in wrappers fixtures. Updated setup.py to include the new wrapper entry point. Added the logstash plugin to the wrapper module. made the default the localhost for host. Added an if around the use redis bool. If Redis parameters are not defined, use an empty dict to use all defaults. Change-Id: Iee950a7d05a56d3a45b5f93ccd77306b37662d25
This commit is contained in:
parent
a32288a573
commit
98579924ef
@ -863,6 +863,66 @@ def pre_scm_buildstep(parser, xml_parent, data):
|
||||
bs.append(edited_node)
|
||||
|
||||
|
||||
def logstash(parser, xml_parent, data):
|
||||
"""yaml: logstash build wrapper
|
||||
Dump the Jenkins console output to Logstash
|
||||
Requires the Jenkins `logstash plugin.
|
||||
<https://wiki.jenkins-ci.org/display/JENKINS/Logstash+Plugin>`_
|
||||
|
||||
:arg use-redis: Boolean to use Redis. (default: true)
|
||||
:arg redis: Redis config params
|
||||
|
||||
:Parameter: * **host** (`str`) Redis hostname\
|
||||
(default 'localhost')
|
||||
:Parameter: * **port** (`int`) Redis port number (default 6397)
|
||||
:Parameter: * **database-number** (`int`)\
|
||||
Redis database number (default 0)
|
||||
:Parameter: * **database-password** (`str`)\
|
||||
Redis database password (default '')
|
||||
:Parameter: * **data-type** (`str`)\
|
||||
Redis database type (default 'list')
|
||||
:Parameter: * **key** (`str`) Redis key (default 'logstash')
|
||||
|
||||
Example:
|
||||
|
||||
.. literalinclude:: /../../tests/wrappers/fixtures/logstash001.yaml
|
||||
|
||||
"""
|
||||
logstash = XML.SubElement(xml_parent,
|
||||
'jenkins.plugins.logstash.'
|
||||
'LogstashBuildWrapper')
|
||||
logstash.set('plugin', 'logstash@0.8.0')
|
||||
|
||||
redis_bool = XML.SubElement(logstash, 'useRedis')
|
||||
redis_bool.text = str(data.get('use-redis', True)).lower()
|
||||
|
||||
if data.get('use-redis'):
|
||||
redis_config = data.get('redis', {})
|
||||
redis_sub_element = XML.SubElement(logstash, 'redis')
|
||||
|
||||
host_sub_element = XML.SubElement(redis_sub_element, 'host')
|
||||
host_sub_element.text = str(
|
||||
redis_config.get('host', 'localhost'))
|
||||
|
||||
port_sub_element = XML.SubElement(redis_sub_element, 'port')
|
||||
port_sub_element.text = str(redis_config.get('port', '6379'))
|
||||
|
||||
database_numb_sub_element = XML.SubElement(redis_sub_element, 'numb')
|
||||
database_numb_sub_element.text = \
|
||||
str(redis_config.get('database-number', '0'))
|
||||
|
||||
database_pass_sub_element = XML.SubElement(redis_sub_element, 'pass')
|
||||
database_pass_sub_element.text = \
|
||||
str(redis_config.get('database-password', ''))
|
||||
|
||||
data_type_sub_element = XML.SubElement(redis_sub_element, 'dataType')
|
||||
data_type_sub_element.text = \
|
||||
str(redis_config.get('data-type', 'list'))
|
||||
|
||||
key_sub_element = XML.SubElement(redis_sub_element, 'key')
|
||||
key_sub_element.text = str(redis_config.get('key', 'logstash'))
|
||||
|
||||
|
||||
class Wrappers(jenkins_jobs.modules.base.Base):
|
||||
sequence = 80
|
||||
|
||||
|
1
setup.py
1
setup.py
@ -202,6 +202,7 @@ setuptools.setup(
|
||||
'inject-passwords=jenkins_jobs.modules.wrappers:inject_passwords',
|
||||
'jclouds=jenkins_jobs.modules.wrappers:jclouds',
|
||||
'locks=jenkins_jobs.modules.wrappers:locks',
|
||||
'logstash=jenkins_jobs.modules.wrappers:logstash',
|
||||
'mask-passwords=jenkins_jobs.modules.wrappers:mask_passwords',
|
||||
'pathignore=jenkins_jobs.modules.wrappers:pathignore',
|
||||
'port-allocator=jenkins_jobs.modules.wrappers:port_allocator',
|
||||
|
16
tests/wrappers/fixtures/logstash001.xml
Normal file
16
tests/wrappers/fixtures/logstash001.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<buildWrappers>
|
||||
<jenkins.plugins.logstash.LogstashBuildWrapper plugin="logstash@0.8.0">
|
||||
<useRedis>true</useRedis>
|
||||
<redis>
|
||||
<host>localhost</host>
|
||||
<port>6379</port>
|
||||
<numb>0</numb>
|
||||
<pass>password</pass>
|
||||
<dataType>list</dataType>
|
||||
<key>logstash</key>
|
||||
</redis>
|
||||
</jenkins.plugins.logstash.LogstashBuildWrapper>
|
||||
</buildWrappers>
|
||||
</project>
|
10
tests/wrappers/fixtures/logstash001.yaml
Normal file
10
tests/wrappers/fixtures/logstash001.yaml
Normal file
@ -0,0 +1,10 @@
|
||||
wrappers:
|
||||
- logstash:
|
||||
use-redis: True
|
||||
redis:
|
||||
host: 'localhost'
|
||||
port: 6379
|
||||
database-number: 0
|
||||
database-password: 'password'
|
||||
data-type: 'list'
|
||||
key: 'logstash'
|
16
tests/wrappers/fixtures/logstash002.xml
Normal file
16
tests/wrappers/fixtures/logstash002.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<buildWrappers>
|
||||
<jenkins.plugins.logstash.LogstashBuildWrapper plugin="logstash@0.8.0">
|
||||
<useRedis>true</useRedis>
|
||||
<redis>
|
||||
<host>localhost</host>
|
||||
<port>6379</port>
|
||||
<numb>0</numb>
|
||||
<pass/>
|
||||
<dataType>list</dataType>
|
||||
<key>logstash</key>
|
||||
</redis>
|
||||
</jenkins.plugins.logstash.LogstashBuildWrapper>
|
||||
</buildWrappers>
|
||||
</project>
|
3
tests/wrappers/fixtures/logstash002.yaml
Normal file
3
tests/wrappers/fixtures/logstash002.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
wrappers:
|
||||
- logstash:
|
||||
use-redis: True
|
8
tests/wrappers/fixtures/logstash003.xml
Normal file
8
tests/wrappers/fixtures/logstash003.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<buildWrappers>
|
||||
<jenkins.plugins.logstash.LogstashBuildWrapper plugin="logstash@0.8.0">
|
||||
<useRedis>false</useRedis>
|
||||
</jenkins.plugins.logstash.LogstashBuildWrapper>
|
||||
</buildWrappers>
|
||||
</project>
|
3
tests/wrappers/fixtures/logstash003.yaml
Normal file
3
tests/wrappers/fixtures/logstash003.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
wrappers:
|
||||
- logstash:
|
||||
use-redis: False
|
Loading…
Reference in New Issue
Block a user