Merge "Ruby metrics plugin support added"

This commit is contained in:
Jenkins 2014-03-14 21:08:21 +00:00 committed by Gerrit Code Review
commit de4aff166f
4 changed files with 82 additions and 0 deletions

View File

@ -3369,6 +3369,53 @@ def artifact_deployer(parser, xml_parent, data):
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):
sequence = 70

View File

@ -171,6 +171,7 @@ setuptools.setup(
'plot=jenkins_jobs.modules.publishers:plot',
'post-tasks=jenkins_jobs.modules.publishers:post_tasks',
'robot=jenkins_jobs.modules.publishers:robot',
'ruby-metrics=jenkins_jobs.modules.publishers:ruby_metrics',
'scp=jenkins_jobs.modules.publishers:scp',
'sloccount=jenkins_jobs.modules.publishers:sloccount',
'sonar=jenkins_jobs.modules.publishers:sonar',

View 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>

View 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