Merge "Add FindBugs support to Publishers"
This commit is contained in:
commit
6c3cf55400
@ -156,3 +156,17 @@ def config_file_provider_settings(xml_parent, data):
|
|||||||
else:
|
else:
|
||||||
XML.SubElement(xml_parent, 'globalSettings',
|
XML.SubElement(xml_parent, 'globalSettings',
|
||||||
{'class': settings['default-global-settings']})
|
{'class': settings['default-global-settings']})
|
||||||
|
|
||||||
|
|
||||||
|
def findbugs_settings(xml_parent, data):
|
||||||
|
# General Options
|
||||||
|
rank_priority = str(data.get('rank-priority', False)).lower()
|
||||||
|
XML.SubElement(xml_parent, 'isRankActivated').text = rank_priority
|
||||||
|
include_files = data.get('include-files', '')
|
||||||
|
XML.SubElement(xml_parent, 'includePattern').text = include_files
|
||||||
|
exclude_files = data.get('exclude-files', '')
|
||||||
|
XML.SubElement(xml_parent, 'excludePattern').text = exclude_files
|
||||||
|
use_previous_build = str(data.get('use-previous-build-as-reference',
|
||||||
|
False)).lower()
|
||||||
|
XML.SubElement(xml_parent,
|
||||||
|
'usePreviousBuildAsReference').text = use_previous_build
|
||||||
|
@ -30,6 +30,7 @@ import xml.etree.ElementTree as XML
|
|||||||
import jenkins_jobs.modules.base
|
import jenkins_jobs.modules.base
|
||||||
from jenkins_jobs.modules import hudson_model
|
from jenkins_jobs.modules import hudson_model
|
||||||
from jenkins_jobs.modules.helpers import build_trends_publisher
|
from jenkins_jobs.modules.helpers import build_trends_publisher
|
||||||
|
from jenkins_jobs.modules.helpers import findbugs_settings
|
||||||
from jenkins_jobs.errors import JenkinsJobsException
|
from jenkins_jobs.errors import JenkinsJobsException
|
||||||
import logging
|
import logging
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
@ -1074,6 +1075,77 @@ def violations(parser, xml_parent, data):
|
|||||||
XML.SubElement(config, 'encoding').text = 'default'
|
XML.SubElement(config, 'encoding').text = 'default'
|
||||||
|
|
||||||
|
|
||||||
|
def findbugs(parser, xml_parent, data):
|
||||||
|
"""yaml: findbugs
|
||||||
|
FindBugs reporting for builds
|
||||||
|
|
||||||
|
Requires the Jenkins :jenkins-wiki:`FindBugs Plugin
|
||||||
|
<FindBugs+Plugin>`.
|
||||||
|
|
||||||
|
:arg str pattern: specifies the generated raw FindBugs XML report files,
|
||||||
|
such as \*\*/findbugs.xml or \*\*/findbugsXml.xml.
|
||||||
|
(Optional)
|
||||||
|
:arg bool rank-priority: Use rank as priority (default: false)
|
||||||
|
:arg str include-files: Comma separated list of files to include.
|
||||||
|
(Optional)
|
||||||
|
:arg str exclude-files: Comma separated list of files to exclude.
|
||||||
|
(Optional)
|
||||||
|
:arg bool can-run-on-failed: Weather or not to run plug-in on failed builds
|
||||||
|
(default: false)
|
||||||
|
:arg bool should-detect-modules: Determines if Ant or Maven modules should
|
||||||
|
be detected for all files that contain
|
||||||
|
warnings. (default: false)
|
||||||
|
:arg int healthy: Sunny threshold (optional)
|
||||||
|
:arg int unhealthy: Stormy threshold (optional)
|
||||||
|
:arg str health-threshold: Threshold priority for health status
|
||||||
|
('low', 'normal' or 'high', defaulted to 'low')
|
||||||
|
:arg bool dont-compute-new: If set to false, computes new warnings based on
|
||||||
|
the reference build (default true)
|
||||||
|
:arg bool use-delta-values: Use delta for new warnings. (Default: false)
|
||||||
|
:arg bool use-previous-build-as-reference: If set then the number of new
|
||||||
|
warnings will always be calculated based on the previous build. Otherwise
|
||||||
|
the reference build. (Default: false)
|
||||||
|
:arg bool use-stable-build-as-reference: The number of new warnings will be
|
||||||
|
calculated based on the last stable build, allowing reverts of unstable
|
||||||
|
builds where the number of warnings was decreased. (default false)
|
||||||
|
:arg dict thresholds:
|
||||||
|
:thresholds:
|
||||||
|
* **unstable** (`dict`)
|
||||||
|
:unstable: * **total-all** (`int`)
|
||||||
|
* **total-high** (`int`)
|
||||||
|
* **total-normal** (`int`)
|
||||||
|
* **total-low** (`int`)
|
||||||
|
* **new-all** (`int`)
|
||||||
|
* **new-high** (`int`)
|
||||||
|
* **new-normal** (`int`)
|
||||||
|
* **new-low** (`int`)
|
||||||
|
|
||||||
|
* **failed** (`dict`)
|
||||||
|
:failed: * **total-all** (`int`)
|
||||||
|
* **total-high** (`int`)
|
||||||
|
* **total-normal** (`int`)
|
||||||
|
* **total-low** (`int`)
|
||||||
|
* **new-all** (`int`)
|
||||||
|
* **new-high** (`int`)
|
||||||
|
* **new-normal** (`int`)
|
||||||
|
* **new-low** (`int`)
|
||||||
|
|
||||||
|
Minimal Example:
|
||||||
|
|
||||||
|
.. literalinclude:: /../../tests/reporters/fixtures/findbugs-minimal.yaml
|
||||||
|
|
||||||
|
Full Example:
|
||||||
|
|
||||||
|
.. literalinclude:: /../../tests/publishers/fixtures/findbugs01.yaml
|
||||||
|
"""
|
||||||
|
findbugs = XML.SubElement(xml_parent,
|
||||||
|
'hudson.plugins.findbugs.FindBugsPublisher')
|
||||||
|
findbugs.set('plugin', 'findbugs')
|
||||||
|
|
||||||
|
findbugs_settings(findbugs, data)
|
||||||
|
build_trends_publisher('[FINDBUGS] ', findbugs, data)
|
||||||
|
|
||||||
|
|
||||||
def checkstyle(parser, xml_parent, data):
|
def checkstyle(parser, xml_parent, data):
|
||||||
"""yaml: checkstyle
|
"""yaml: checkstyle
|
||||||
Publish trend reports with Checkstyle.
|
Publish trend reports with Checkstyle.
|
||||||
|
@ -35,6 +35,7 @@ Example::
|
|||||||
import xml.etree.ElementTree as XML
|
import xml.etree.ElementTree as XML
|
||||||
import jenkins_jobs.modules.base
|
import jenkins_jobs.modules.base
|
||||||
from jenkins_jobs.modules.helpers import build_trends_publisher
|
from jenkins_jobs.modules.helpers import build_trends_publisher
|
||||||
|
from jenkins_jobs.modules.helpers import findbugs_settings
|
||||||
from jenkins_jobs.errors import JenkinsJobsException
|
from jenkins_jobs.errors import JenkinsJobsException
|
||||||
|
|
||||||
|
|
||||||
@ -132,18 +133,7 @@ def findbugs(parser, xml_parent, data):
|
|||||||
'hudson.plugins.findbugs.FindBugsReporter')
|
'hudson.plugins.findbugs.FindBugsReporter')
|
||||||
findbugs.set('plugin', 'findbugs')
|
findbugs.set('plugin', 'findbugs')
|
||||||
|
|
||||||
# General Options
|
findbugs_settings(findbugs, data)
|
||||||
rank_priority = str(data.get('rank-priority', False)).lower()
|
|
||||||
XML.SubElement(findbugs, 'isRankActivated').text = rank_priority
|
|
||||||
include_files = data.get('include-files', '')
|
|
||||||
XML.SubElement(findbugs, 'includePattern').text = include_files
|
|
||||||
exclude_files = data.get('exclude-files', '')
|
|
||||||
XML.SubElement(findbugs, 'excludePattern').text = exclude_files
|
|
||||||
use_previous_build = str(data.get('use-previous-build-as-reference',
|
|
||||||
False)).lower()
|
|
||||||
XML.SubElement(findbugs,
|
|
||||||
'usePreviousBuildAsReference').text = use_previous_build
|
|
||||||
|
|
||||||
build_trends_publisher('[FINDBUGS] ', findbugs, data)
|
build_trends_publisher('[FINDBUGS] ', findbugs, data)
|
||||||
|
|
||||||
|
|
||||||
|
@ -145,6 +145,7 @@ jenkins_jobs.publishers =
|
|||||||
email-ext=jenkins_jobs.modules.publishers:email_ext
|
email-ext=jenkins_jobs.modules.publishers:email_ext
|
||||||
email=jenkins_jobs.modules.publishers:email
|
email=jenkins_jobs.modules.publishers:email
|
||||||
emotional-jenkins=jenkins_jobs.modules.publishers:emotional_jenkins
|
emotional-jenkins=jenkins_jobs.modules.publishers:emotional_jenkins
|
||||||
|
findbugs=jenkins_jobs.modules.publishers:findbugs
|
||||||
fingerprint=jenkins_jobs.modules.publishers:fingerprint
|
fingerprint=jenkins_jobs.modules.publishers:fingerprint
|
||||||
fitnesse=jenkins_jobs.modules.publishers:fitnesse
|
fitnesse=jenkins_jobs.modules.publishers:fitnesse
|
||||||
ftp=jenkins_jobs.modules.publishers:ftp
|
ftp=jenkins_jobs.modules.publishers:ftp
|
||||||
|
41
tests/publishers/fixtures/findbugs01.xml
Normal file
41
tests/publishers/fixtures/findbugs01.xml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<publishers>
|
||||||
|
<hudson.plugins.findbugs.FindBugsPublisher plugin="findbugs">
|
||||||
|
<isRankActivated>true</isRankActivated>
|
||||||
|
<includePattern>f,d,e,.*</includePattern>
|
||||||
|
<excludePattern>a,c,d,.*</excludePattern>
|
||||||
|
<usePreviousBuildAsReference>true</usePreviousBuildAsReference>
|
||||||
|
<healthy>80</healthy>
|
||||||
|
<unHealthy>10</unHealthy>
|
||||||
|
<thresholdLimit>high</thresholdLimit>
|
||||||
|
<pluginName>[FINDBUGS] </pluginName>
|
||||||
|
<defaultEncoding/>
|
||||||
|
<canRunOnFailed>true</canRunOnFailed>
|
||||||
|
<useStableBuildAsReference>true</useStableBuildAsReference>
|
||||||
|
<useDeltaValues>true</useDeltaValues>
|
||||||
|
<thresholds>
|
||||||
|
<unstableTotalAll>90</unstableTotalAll>
|
||||||
|
<unstableTotalHigh>80</unstableTotalHigh>
|
||||||
|
<unstableTotalNormal>50</unstableTotalNormal>
|
||||||
|
<unstableTotalLow>20</unstableTotalLow>
|
||||||
|
<unstableNewAll>95</unstableNewAll>
|
||||||
|
<unstableNewHigh>85</unstableNewHigh>
|
||||||
|
<unstableNewNormal>55</unstableNewNormal>
|
||||||
|
<unstableNewLow>25</unstableNewLow>
|
||||||
|
<failedTotalAll>80</failedTotalAll>
|
||||||
|
<failedTotalHigh>70</failedTotalHigh>
|
||||||
|
<failedTotalNormal>40</failedTotalNormal>
|
||||||
|
<failedTotalLow>10</failedTotalLow>
|
||||||
|
<failedNewAll>85</failedNewAll>
|
||||||
|
<failedNewHigh>75</failedNewHigh>
|
||||||
|
<failedNewNormal>45</failedNewNormal>
|
||||||
|
<failedNewLow>15</failedNewLow>
|
||||||
|
</thresholds>
|
||||||
|
<shouldDetectModules>true</shouldDetectModules>
|
||||||
|
<dontComputeNew>false</dontComputeNew>
|
||||||
|
<doNotResolveRelativePaths>false</doNotResolveRelativePaths>
|
||||||
|
<pattern>**/findbugs.xml</pattern>
|
||||||
|
</hudson.plugins.findbugs.FindBugsPublisher>
|
||||||
|
</publishers>
|
||||||
|
</project>
|
35
tests/publishers/fixtures/findbugs01.yaml
Normal file
35
tests/publishers/fixtures/findbugs01.yaml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
publishers:
|
||||||
|
- findbugs:
|
||||||
|
pattern: '**/findbugs.xml'
|
||||||
|
rank-priority: true
|
||||||
|
include-files: 'f,d,e,.*'
|
||||||
|
exclude-files: 'a,c,d,.*'
|
||||||
|
can-run-on-failed: true
|
||||||
|
should-detect-modules: true
|
||||||
|
healthy: 80
|
||||||
|
unhealthy: 10
|
||||||
|
use-delta-values: true
|
||||||
|
health-threshold: 'high'
|
||||||
|
thresholds:
|
||||||
|
unstable:
|
||||||
|
total-all: 90
|
||||||
|
total-high: 80
|
||||||
|
total-normal: 50
|
||||||
|
total-low: 20
|
||||||
|
new-all: 95
|
||||||
|
new-high: 85
|
||||||
|
new-normal: 55
|
||||||
|
new-low: 25
|
||||||
|
failed:
|
||||||
|
total-all: 80
|
||||||
|
total-high: 70
|
||||||
|
total-normal: 40
|
||||||
|
total-low: 10
|
||||||
|
new-all: 85
|
||||||
|
new-high: 75
|
||||||
|
new-normal: 45
|
||||||
|
new-low: 15
|
||||||
|
dont-compute-new: false
|
||||||
|
use-delta-values: true
|
||||||
|
use-previous-build-as-reference: true
|
||||||
|
use-stable-build-as-reference: true
|
Loading…
x
Reference in New Issue
Block a user