Ruby metrics plugin support added
Rcov plugin parses rcov html report files and shows it in Jenkins with a trend graph. Change-Id: I1f1d177c8681e68e5c12b520e263648842c701d0
This commit is contained in:
parent
bed596e8c6
commit
305c313da3
@ -3355,6 +3355,53 @@ def artifact_deployer(parser, xml_parent, data):
|
|||||||
XML.SubElement(deployer, 'deployEvenBuildFail').text = deploy_if_fail
|
XML.SubElement(deployer, 'deployEvenBuildFail').text = deploy_if_fail
|
||||||
|
|
||||||
|
|
||||||
|
def ruby_metrics(parser, xml_parent, data):
|
||||||
|
"""yaml: ruby-metrics
|
||||||
|
Rcov plugin parses rcov html report files and
|
||||||
|
shows it in Jenkins with a trend graph.
|
||||||
|
|
||||||
|
Requires the Jenkins `Ruby metrics plugin.
|
||||||
|
<https://wiki.jenkins-ci.org/display/JENKINS/Ruby+metrics+plugin>`_
|
||||||
|
|
||||||
|
:arg str report-dir: Relative path to the coverage report directory
|
||||||
|
:arg dict targets:
|
||||||
|
|
||||||
|
:targets: (total-coverage, code-coverage)
|
||||||
|
|
||||||
|
* **healthy** (`int`): Healthy threshold
|
||||||
|
* **unhealthy** (`int`): Unhealthy threshold
|
||||||
|
* **unstable** (`int`): Unstable threshold
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
.. literalinclude:: /../../tests/publishers/fixtures/ruby-metrics.yaml
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
metrics = XML.SubElement(
|
||||||
|
xml_parent,
|
||||||
|
'hudson.plugins.rubyMetrics.rcov.RcovPublisher')
|
||||||
|
report_dir = data.get('report-dir', '')
|
||||||
|
XML.SubElement(metrics, 'reportDir').text = report_dir
|
||||||
|
targets = XML.SubElement(metrics, 'targets')
|
||||||
|
if 'target' in data:
|
||||||
|
for t in data['target']:
|
||||||
|
if not ('code-coverage' in t or 'total-coverage' in t):
|
||||||
|
raise JenkinsJobsException('Unrecognized target name')
|
||||||
|
el = XML.SubElement(
|
||||||
|
targets,
|
||||||
|
'hudson.plugins.rubyMetrics.rcov.model.MetricTarget')
|
||||||
|
if 'total-coverage' in t:
|
||||||
|
XML.SubElement(el, 'metric').text = 'TOTAL_COVERAGE'
|
||||||
|
else:
|
||||||
|
XML.SubElement(el, 'metric').text = 'CODE_COVERAGE'
|
||||||
|
for threshold_name, threshold_value in t.values()[0].items():
|
||||||
|
elname = threshold_name.lower()
|
||||||
|
XML.SubElement(el, elname).text = str(threshold_value)
|
||||||
|
else:
|
||||||
|
raise JenkinsJobsException('Coverage metric targets must be set')
|
||||||
|
|
||||||
|
|
||||||
class Publishers(jenkins_jobs.modules.base.Base):
|
class Publishers(jenkins_jobs.modules.base.Base):
|
||||||
sequence = 70
|
sequence = 70
|
||||||
|
|
||||||
|
1
setup.py
1
setup.py
@ -169,6 +169,7 @@ setuptools.setup(
|
|||||||
'plot=jenkins_jobs.modules.publishers:plot',
|
'plot=jenkins_jobs.modules.publishers:plot',
|
||||||
'post-tasks=jenkins_jobs.modules.publishers:post_tasks',
|
'post-tasks=jenkins_jobs.modules.publishers:post_tasks',
|
||||||
'robot=jenkins_jobs.modules.publishers:robot',
|
'robot=jenkins_jobs.modules.publishers:robot',
|
||||||
|
'ruby-metrics=jenkins_jobs.modules.publishers:ruby_metrics',
|
||||||
'scp=jenkins_jobs.modules.publishers:scp',
|
'scp=jenkins_jobs.modules.publishers:scp',
|
||||||
'sloccount=jenkins_jobs.modules.publishers:sloccount',
|
'sloccount=jenkins_jobs.modules.publishers:sloccount',
|
||||||
'sonar=jenkins_jobs.modules.publishers:sonar',
|
'sonar=jenkins_jobs.modules.publishers:sonar',
|
||||||
|
22
tests/publishers/fixtures/ruby-metrics.xml
Normal file
22
tests/publishers/fixtures/ruby-metrics.xml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<publishers>
|
||||||
|
<hudson.plugins.rubyMetrics.rcov.RcovPublisher>
|
||||||
|
<reportDir>coverage/rcov</reportDir>
|
||||||
|
<targets>
|
||||||
|
<hudson.plugins.rubyMetrics.rcov.model.MetricTarget>
|
||||||
|
<metric>TOTAL_COVERAGE</metric>
|
||||||
|
<healthy>80</healthy>
|
||||||
|
<unstable>0</unstable>
|
||||||
|
<unhealthy>0</unhealthy>
|
||||||
|
</hudson.plugins.rubyMetrics.rcov.model.MetricTarget>
|
||||||
|
<hudson.plugins.rubyMetrics.rcov.model.MetricTarget>
|
||||||
|
<metric>CODE_COVERAGE</metric>
|
||||||
|
<healthy>80</healthy>
|
||||||
|
<unstable>0</unstable>
|
||||||
|
<unhealthy>0</unhealthy>
|
||||||
|
</hudson.plugins.rubyMetrics.rcov.model.MetricTarget>
|
||||||
|
</targets>
|
||||||
|
</hudson.plugins.rubyMetrics.rcov.RcovPublisher>
|
||||||
|
</publishers>
|
||||||
|
</project>
|
12
tests/publishers/fixtures/ruby-metrics.yaml
Normal file
12
tests/publishers/fixtures/ruby-metrics.yaml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
publishers:
|
||||||
|
- ruby-metrics:
|
||||||
|
report-dir: "coverage/rcov"
|
||||||
|
target:
|
||||||
|
- total-coverage:
|
||||||
|
healthy: 80
|
||||||
|
unhealthy: 0
|
||||||
|
unstable: 0
|
||||||
|
- code-coverage:
|
||||||
|
healthy: 80
|
||||||
|
unhealthy: 0
|
||||||
|
unstable: 0
|
Loading…
Reference in New Issue
Block a user