summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDong Ma <winterma.dong@gmail.com>2016-09-27 11:06:13 -0700
committerDong Ma <winterma.dong@gmail.com>2016-10-07 23:36:52 -0700
commit3a226228b5432f1e21c834ea18db974d0889e866 (patch)
tree47459de64abc4c12fa2af891648246577064623e
parentb56481cf8cefd290cd31752ed54fdefca6c56feb (diff)
downloadpython-jenkins-job-builder-3a226228b5432f1e21c834ea18db974d0889e866.tar.gz
python-jenkins-job-builder-3a226228b5432f1e21c834ea18db974d0889e866.tar.xz
python-jenkins-job-builder-3a226228b5432f1e21c834ea18db974d0889e866.zip
Update cppcheck plugin
- update cppcheck plugin to use convert xml - update cppcheck plugin docstring - add plugin="cppcheck" attribute - add new parameters for cppcheck plugin - update test cases Change-Id: Id17f4fb082eff1ed9266f98454f1e1df2bcaca7f
-rw-r--r--jenkins_jobs/modules/publishers.py133
-rw-r--r--tests/publishers/fixtures/cppcheck-complete.xml40
-rw-r--r--tests/publishers/fixtures/cppcheck-complete.yaml (renamed from tests/publishers/fixtures/cppcheck001.yaml)21
-rw-r--r--tests/publishers/fixtures/cppcheck-minimal.xml (renamed from tests/publishers/fixtures/cppcheck001.xml)22
-rw-r--r--tests/publishers/fixtures/cppcheck-minimal.yaml3
5 files changed, 170 insertions, 49 deletions
diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py
index 60a49da2..bedbc64a 100644
--- a/jenkins_jobs/modules/publishers.py
+++ b/jenkins_jobs/modules/publishers.py
@@ -2081,65 +2081,122 @@ def cppcheck(registry, xml_parent, data):
Cppcheck result publisher
Requires the Jenkins :jenkins-wiki:`Cppcheck Plugin <Cppcheck+Plugin>`.
- :arg str pattern: file pattern for cppcheck xml report
+ :arg str pattern: File pattern for cppcheck xml report (required)
+ :arg bool ignoreblankfiles: Ignore blank files (default false)
+ :arg bool allow-no-report: Do not fail the build if the Cppcheck report
+ is not found (default false)
+ :arg dict thresholds:
+ :thresholds: Configure the build status and health. A build is
+ considered as unstable or failure if the new or total number
+ of issues exceeds the specified thresholds. The build health
+ is also determined by thresholds. If the actual number of issues
+ is between the provided thresholds, then the build health is
+ interpolated.
+ * **unstable** (`str`): Total number unstable threshold (default '')
+ * **new-unstable** (`str`): New number unstable threshold (default '')
+ * **failure** (`str`): Total number failure threshold (default '')
+ * **new-failure** (`str`): New number failure threshold (default '')
+ * **healthy** (`str`): Healthy threshold (default '')
+ * **unhealthy** (`str`): Unhealthy threshold (default '')
+ :arg dict severity:
+ :severity: Determines which severity of issues should be considered
+ when evaluating the build status and health, default all true
+ * **error** (`bool`): Severity error (default true)
+ * **warning** (`bool`): Severity warning (default true)
+ * **style** (`bool`): Severity style (default true)
+ * **performance** (`bool`): Severity performance (default true)
+ * **information** (`bool`): Severity information (default true)
+ * **nocategory** (`bool`): Severity nocategory (default true)
+ * **portability** (`bool`): Severity portability (default true)
+ :arg dict graph:
+ :graph: Graph configuration
+ * **xysize** (`array`): Chart width and height (default [500, 200])
+ * **num-builds-in-graph** (`int`): Builds number in graph (default 0)
+ :arg dict display
+ :display: which errors to display, default only sum
+ * **sum** (`bool`): Display sum of all issues (default true)
+ * **error** (`bool`): Display errors (default false)
+ * **warning** (`bool`): Display warnings (default false)
+ * **style** (`bool`): Display style (default false)
+ * **performance** (`bool`): Display performance (default false)
+ * **information** (`bool`): Display information (default false)
+ * **nocategory** (`bool`): Display no category (default false)
+ * **portability** (`bool`): Display portability (default false)
- for more optional parameters see the example
+ Minimal Example:
- Example:
+ .. literalinclude::
+ /../../tests/publishers/fixtures/cppcheck-minimal.yaml
+ :language: yaml
- .. literalinclude:: /../../tests/publishers/fixtures/cppcheck001.yaml
+ Full Example:
+ .. literalinclude::
+ /../../tests/publishers/fixtures/cppcheck-complete.yaml
:language: yaml
"""
+
cppextbase = XML.SubElement(xml_parent,
'org.jenkinsci.plugins.cppcheck.'
'CppcheckPublisher')
+ cppextbase.set('plugin', 'cppcheck')
cppext = XML.SubElement(cppextbase, 'cppcheckConfig')
- XML.SubElement(cppext, 'pattern').text = data['pattern']
- XML.SubElement(cppext, 'ignoreBlankFiles').text = \
- str(data.get('ignoreblankfiles', False)).lower()
+ mappings = [
+ ('pattern', 'pattern', None),
+ ('ignoreblankfiles', 'ignoreBlankFiles', False),
+ ('allow-no-report', 'allowNoReport', False)
+ ]
+ helpers.convert_mapping_to_xml(cppext, data, mappings, fail_required=True)
csev = XML.SubElement(cppext, 'configSeverityEvaluation')
thrsh = data.get('thresholds', {})
- XML.SubElement(csev, 'threshold').text = str(thrsh.get('unstable', ''))
- XML.SubElement(csev, 'newThreshold').text = \
- str(thrsh.get('new-unstable', ''))
- XML.SubElement(csev, 'failureThreshold').text = \
- str(thrsh.get('failure', ''))
- XML.SubElement(csev, 'newFailureThreshold').text = \
- str(thrsh.get('new-failure', ''))
- XML.SubElement(csev, 'healthy').text = str(thrsh.get('healthy', ''))
- XML.SubElement(csev, 'unHealthy').text = str(thrsh.get('unhealthy', ''))
+ thrsh_mappings = [
+ ('unstable', 'threshold', ''),
+ ('new-unstable', 'newThreshold', ''),
+ ('failure', 'failureThreshold', ''),
+ ('new-failure', 'newFailureThreshold', ''),
+ ('healthy', 'healthy', ''),
+ ('unhealthy', 'unHealthy', '')
+ ]
+ helpers.convert_mapping_to_xml(
+ csev, thrsh, thrsh_mappings, fail_required=True)
sev = thrsh.get('severity', {})
- XML.SubElement(csev, 'severityError').text = \
- str(sev.get('error', True)).lower()
- XML.SubElement(csev, 'severityWarning').text = \
- str(sev.get('warning', True)).lower()
- XML.SubElement(csev, 'severityStyle').text = \
- str(sev.get('style', True)).lower()
- XML.SubElement(csev, 'severityPerformance').text = \
- str(sev.get('performance', True)).lower()
- XML.SubElement(csev, 'severityInformation').text = \
- str(sev.get('information', True)).lower()
+ sev_mappings = [
+ ('error', 'severityError', True),
+ ('warning', 'severityWarning', True),
+ ('style', 'severityStyle', True),
+ ('performance', 'severityPerformance', True),
+ ('information', 'severityInformation', True),
+ ('nocategory', 'severityNoCategory', True),
+ ('portability', 'severityPortability', True)
+ ]
+ helpers.convert_mapping_to_xml(
+ csev, sev, sev_mappings, fail_required=True)
graph = data.get('graph', {})
cgraph = XML.SubElement(cppext, 'configGraph')
x, y = graph.get('xysize', [500, 200])
XML.SubElement(cgraph, 'xSize').text = str(x)
XML.SubElement(cgraph, 'ySize').text = str(y)
+ graph_mapping = [
+ ('num-builds-in-graph', 'numBuildsInGraph', 0)
+ ]
+ helpers.convert_mapping_to_xml(
+ cgraph, graph, graph_mapping, fail_required=True)
+
gdisplay = graph.get('display', {})
- XML.SubElement(cgraph, 'displayAllErrors').text = \
- str(gdisplay.get('sum', True)).lower()
- XML.SubElement(cgraph, 'displayErrorSeverity').text = \
- str(gdisplay.get('error', False)).lower()
- XML.SubElement(cgraph, 'displayWarningSeverity').text = \
- str(gdisplay.get('warning', False)).lower()
- XML.SubElement(cgraph, 'displayStyleSeverity').text = \
- str(gdisplay.get('style', False)).lower()
- XML.SubElement(cgraph, 'displayPerformanceSeverity').text = \
- str(gdisplay.get('performance', False)).lower()
- XML.SubElement(cgraph, 'displayInformationSeverity').text = \
- str(gdisplay.get('information', False)).lower()
+ gdisplay_mappings = [
+ ('sum', 'displayAllErrors', True),
+ ('error', 'displayErrorSeverity', False),
+ ('warning', 'displayWarningSeverity', False),
+ ('style', 'displayStyleSeverity', False),
+ ('performance', 'displayPerformanceSeverity', False),
+ ('information', 'displayInformationSeverity', False),
+ ('nocategory', 'displayNoCategorySeverity', False),
+ ('portability', 'displayPortabilitySeverity', False)
+ ]
+ helpers.convert_mapping_to_xml(
+ cgraph, gdisplay, gdisplay_mappings, fail_required=True)
def logparser(registry, xml_parent, data):
diff --git a/tests/publishers/fixtures/cppcheck-complete.xml b/tests/publishers/fixtures/cppcheck-complete.xml
new file mode 100644
index 00000000..9932d1d4
--- /dev/null
+++ b/tests/publishers/fixtures/cppcheck-complete.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<project>
+ <publishers>
+ <org.jenkinsci.plugins.cppcheck.CppcheckPublisher plugin="cppcheck">
+ <cppcheckConfig>
+ <pattern>**/cppcheck.xml</pattern>
+ <ignoreBlankFiles>true</ignoreBlankFiles>
+ <allowNoReport>true</allowNoReport>
+ <configSeverityEvaluation>
+ <threshold>5</threshold>
+ <newThreshold>5</newThreshold>
+ <failureThreshold>7</failureThreshold>
+ <newFailureThreshold>3</newFailureThreshold>
+ <healthy>5</healthy>
+ <unHealthy>10</unHealthy>
+ <severityError>false</severityError>
+ <severityWarning>false</severityWarning>
+ <severityStyle>false</severityStyle>
+ <severityPerformance>false</severityPerformance>
+ <severityInformation>false</severityInformation>
+ <severityNoCategory>false</severityNoCategory>
+ <severityPortability>false</severityPortability>
+ </configSeverityEvaluation>
+ <configGraph>
+ <xSize>600</xSize>
+ <ySize>300</ySize>
+ <numBuildsInGraph>10</numBuildsInGraph>
+ <displayAllErrors>false</displayAllErrors>
+ <displayErrorSeverity>true</displayErrorSeverity>
+ <displayWarningSeverity>true</displayWarningSeverity>
+ <displayStyleSeverity>true</displayStyleSeverity>
+ <displayPerformanceSeverity>true</displayPerformanceSeverity>
+ <displayInformationSeverity>true</displayInformationSeverity>
+ <displayNoCategorySeverity>true</displayNoCategorySeverity>
+ <displayPortabilitySeverity>true</displayPortabilitySeverity>
+ </configGraph>
+ </cppcheckConfig>
+ </org.jenkinsci.plugins.cppcheck.CppcheckPublisher>
+ </publishers>
+</project>
diff --git a/tests/publishers/fixtures/cppcheck001.yaml b/tests/publishers/fixtures/cppcheck-complete.yaml
index 34408a7b..b18ba5a3 100644
--- a/tests/publishers/fixtures/cppcheck001.yaml
+++ b/tests/publishers/fixtures/cppcheck-complete.yaml
@@ -2,20 +2,35 @@ publishers:
- cppcheck:
pattern: "**/cppcheck.xml"
# the rest is optional
+ ignoreblankfiles: true
+ allow-no-report: true
# build status (new) error count thresholds
thresholds:
unstable: 5
new-unstable: 5
failure: 7
new-failure: 3
+ healthy: 5
+ unhealthy: 10
# severities which count towards the threshold, default all true
severity:
- error: true
- warning: true
+ error: false
+ warning: false
+ style: false
+ performance: false
information: false
+ nocategory: false
+ portability: false
graph:
- xysize: [500, 200]
+ xysize: [600, 300]
+ num-builds-in-graph: 10
# which errors to display, default only sum
display:
sum: false
error: true
+ warning: true
+ style: true
+ performance: true
+ information: true
+ nocategory: true
+ portability: true
diff --git a/tests/publishers/fixtures/cppcheck001.xml b/tests/publishers/fixtures/cppcheck-minimal.xml
index 65b31032..ff5084b6 100644
--- a/tests/publishers/fixtures/cppcheck001.xml
+++ b/tests/publishers/fixtures/cppcheck-minimal.xml
@@ -1,32 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<publishers>
- <org.jenkinsci.plugins.cppcheck.CppcheckPublisher>
+ <org.jenkinsci.plugins.cppcheck.CppcheckPublisher plugin="cppcheck">
<cppcheckConfig>
<pattern>**/cppcheck.xml</pattern>
<ignoreBlankFiles>false</ignoreBlankFiles>
+ <allowNoReport>false</allowNoReport>
<configSeverityEvaluation>
- <threshold>5</threshold>
- <newThreshold>5</newThreshold>
- <failureThreshold>7</failureThreshold>
- <newFailureThreshold>3</newFailureThreshold>
+ <threshold/>
+ <newThreshold/>
+ <failureThreshold/>
+ <newFailureThreshold/>
<healthy/>
<unHealthy/>
<severityError>true</severityError>
<severityWarning>true</severityWarning>
<severityStyle>true</severityStyle>
<severityPerformance>true</severityPerformance>
- <severityInformation>false</severityInformation>
+ <severityInformation>true</severityInformation>
+ <severityNoCategory>true</severityNoCategory>
+ <severityPortability>true</severityPortability>
</configSeverityEvaluation>
<configGraph>
<xSize>500</xSize>
<ySize>200</ySize>
- <displayAllErrors>false</displayAllErrors>
- <displayErrorSeverity>true</displayErrorSeverity>
+ <numBuildsInGraph>0</numBuildsInGraph>
+ <displayAllErrors>true</displayAllErrors>
+ <displayErrorSeverity>false</displayErrorSeverity>
<displayWarningSeverity>false</displayWarningSeverity>
<displayStyleSeverity>false</displayStyleSeverity>
<displayPerformanceSeverity>false</displayPerformanceSeverity>
<displayInformationSeverity>false</displayInformationSeverity>
+ <displayNoCategorySeverity>false</displayNoCategorySeverity>
+ <displayPortabilitySeverity>false</displayPortabilitySeverity>
</configGraph>
</cppcheckConfig>
</org.jenkinsci.plugins.cppcheck.CppcheckPublisher>
diff --git a/tests/publishers/fixtures/cppcheck-minimal.yaml b/tests/publishers/fixtures/cppcheck-minimal.yaml
new file mode 100644
index 00000000..b7482813
--- /dev/null
+++ b/tests/publishers/fixtures/cppcheck-minimal.yaml
@@ -0,0 +1,3 @@
+publishers:
+ - cppcheck:
+ pattern: "**/cppcheck.xml"