From 9d4eac085d5569848854f87cef7a754f40cc512f Mon Sep 17 00:00:00 2001 From: Kien Ha Date: Mon, 25 Jul 2016 14:10:53 -0400 Subject: [PATCH] Add support for CodeCover plugin Change-Id: I2dc7a8e992e9c148742e4824c17c3f61ee616585 Signed-off-by: Kien Ha --- jenkins_jobs/modules/publishers.py | 49 +++++++++++++++++++ tests/publishers/fixtures/codecover-full.xml | 18 +++++++ tests/publishers/fixtures/codecover-full.yaml | 11 +++++ .../publishers/fixtures/codecover-minimal.xml | 18 +++++++ .../fixtures/codecover-minimal.yaml | 2 + 5 files changed, 98 insertions(+) create mode 100644 tests/publishers/fixtures/codecover-full.xml create mode 100644 tests/publishers/fixtures/codecover-full.yaml create mode 100644 tests/publishers/fixtures/codecover-minimal.xml create mode 100644 tests/publishers/fixtures/codecover-minimal.yaml diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index c3148f759..c2db71127 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -298,6 +298,55 @@ def campfire(parser, xml_parent, data): XML.SubElement(room, 'campfire reference="../../campfire"') +def codecover(parser, xml_parent, data): + """yaml: codecover + This plugin allows you to capture code coverage report from CodeCover. + Jenkins will generate the trend report of coverage. + Requires the Jenkins :jenkins-wiki:`CodeCover Plugin `. + + :arg str include: Specify the path to the CodeCover HTML report file, + relative to the workspace root (default '') + :arg int min-statement: Minimum statement threshold (default 0) + :arg int max-statement: Maximum statement threshold (default 90) + :arg int min-branch: Minimum branch threshold (default 0) + :arg int max-branch: Maximum branch threshold (default 80) + :arg int min-loop: Minimum loop threshold (default 0) + :arg int max-loop: Maximum loop threshold (default 50) + :arg int min-condition: Minimum condition threshold (default 0) + :arg int max-condition: Maximum conditon threshold (default 50) + + Minimal Example: + + .. literalinclude:: /../../tests/publishers/fixtures/codecover-minimal.yaml + :language: yaml + + Full Example: + + .. literalinclude:: /../../tests/publishers/fixtures/codecover-full.yaml + :language: yaml + """ + + codecover = XML.SubElement( + xml_parent, 'hudson.plugins.codecover.CodeCoverPublisher') + codecover.set('plugin', 'codecover') + + XML.SubElement(codecover, 'includes').text = str(data.get('include', '')) + + health_report = XML.SubElement(codecover, 'healthReports') + mapping = [ + ('min-statement', 'minStatement', 0), + ('max-statement', 'maxStatement', 90), + ('min-branch', 'minBranch', 0), + ('max-branch', 'maxBranch', 80), + ('min-loop', 'minLoop', 0), + ('max-loop', 'maxLoop', 50), + ('min-condition', 'minCondition', 0), + ('max-condition', 'maxCondition', 50), + ] + helpers.convert_mapping_to_xml( + health_report, data, mapping, fail_required=True) + + def emotional_jenkins(parser, xml_parent, data): """yaml: emotional-jenkins Emotional Jenkins. This funny plugin changes the expression of Mr. Jenkins diff --git a/tests/publishers/fixtures/codecover-full.xml b/tests/publishers/fixtures/codecover-full.xml new file mode 100644 index 000000000..0f4920fc7 --- /dev/null +++ b/tests/publishers/fixtures/codecover-full.xml @@ -0,0 +1,18 @@ + + + + + ./path/report.html + + 1 + 100 + 2 + 90 + 3 + 80 + 4 + 70 + + + + diff --git a/tests/publishers/fixtures/codecover-full.yaml b/tests/publishers/fixtures/codecover-full.yaml new file mode 100644 index 000000000..5424428f4 --- /dev/null +++ b/tests/publishers/fixtures/codecover-full.yaml @@ -0,0 +1,11 @@ +publishers: + - codecover: + include: ./path/report.html + min-statement: 1 + max-statement: 100 + min-branch: 2 + max-branch: 90 + min-loop: 3 + max-loop: 80 + min-condition: 4 + max-condition: 70 diff --git a/tests/publishers/fixtures/codecover-minimal.xml b/tests/publishers/fixtures/codecover-minimal.xml new file mode 100644 index 000000000..01bbd9624 --- /dev/null +++ b/tests/publishers/fixtures/codecover-minimal.xml @@ -0,0 +1,18 @@ + + + + + + + 0 + 90 + 0 + 80 + 0 + 50 + 0 + 50 + + + + diff --git a/tests/publishers/fixtures/codecover-minimal.yaml b/tests/publishers/fixtures/codecover-minimal.yaml new file mode 100644 index 000000000..83fc95e47 --- /dev/null +++ b/tests/publishers/fixtures/codecover-minimal.yaml @@ -0,0 +1,2 @@ +publishers: + - codecover