Update clang scan build

- Update to use convert_mapping_to_xml
- Add full test
- Add plugin="clang-scanbuild" attribute
- Add support for builders
- Add version number for features  of when they were introduced

Change-Id: I62443ab71ed88a54d283a4fef581d815f90bd95d
Signed-off-by: Kien Ha <kienha9922@gmail.com>
This commit is contained in:
Kien Ha 2016-07-11 11:25:11 -04:00
parent d6add35e72
commit 99e6b5f89c
11 changed files with 149 additions and 18 deletions

View File

@ -2546,6 +2546,69 @@ def github_notifier(parser, xml_parent, data):
'com.cloudbees.jenkins.GitHubSetCommitStatusBuilder')
def scan_build(parser, xml_parent, data):
"""yaml: scan-build
This plugin allows you configure a build step that will execute the Clang
scan-build static analysis tool against an XCode project.
The scan-build report has to be generated in the directory
``${WORKSPACE}/clangScanBuildReports`` for the publisher to find it.
Requires the Jenkins :jenkins-wiki:`Clang Scan-Build Plugin
<Clang+Scan-Build+Plugin>`.
:arg str target: Provide the exact name of the XCode target you wish to
have compiled and analyzed (required)
:arg str target-sdk: Set the simulator version of a currently installed SDK
(default iphonesimulator)
:arg str config: Provide the XCode config you wish to execute scan-build
against (default Debug)
:arg str clang-install-name: Name of clang static analyzer to use (default
'')
:arg str xcode-sub-path: Path of XCode project relative to the workspace
(default '')
:arg str workspace: Name of workspace (default '')
:arg str scheme: Name of scheme (default '')
:arg str scan-build-args: Additional arguments to clang scan-build
(default --use-analyzer Xcode)
:arg str xcode-build-args: Additional arguments to XCode (default
-derivedDataPath $WORKSPACE/build)
:arg str report-folder: Folder where generated reports are located
(>=1.7) (default clangScanBuildReports)
Full Example:
.. literalinclude:: /../../tests/builders/fixtures/scan-build-full.yaml
:language: yaml
Minimal Example:
.. literalinclude::
/../../tests/builders/fixtures/scan-build-minimal.yaml
:language: yaml
"""
p = XML.SubElement(
xml_parent,
'jenkins.plugins.clangscanbuild.ClangScanBuildBuilder')
p.set('plugin', 'clang-scanbuild')
mappings = [
('target', 'target', None),
('target-sdk', 'targetSdk', 'iphonesimulator'),
('config', 'config', 'Debug'),
('clang-install-name', 'clangInstallationName', ''),
('xcode-sub-path', 'xcodeProjectSubPath', 'myProj/subfolder'),
('workspace', 'workspace', ''),
('scheme', 'scheme', ''),
('scan-build-args', 'scanbuildargs', '--use-analyzer Xcode'),
('xcode-build-args',
'xcodebuildargs',
'-derivedDataPath $WORKSPACE/build'),
('report-folder', 'outputFolderName', 'clangScanBuildReports'),
]
convert_mapping_to_xml(p, data, mappings, fail_required=True)
def ssh_builder(parser, xml_parent, data):
"""yaml: ssh-builder
Executes command on remote host

View File

@ -4665,31 +4665,33 @@ def scan_build(parser, xml_parent, data):
exceeds a threshold (default false)
:arg int threshold: Threshold for marking builds as unstable (default 0)
:arg string exclude-paths: Comma separated paths to exclude from reports
(default '')
(>=1.5) (default '')
:arg string report-folder: Folder where generated reports are located
(default 'clangScanBuildReports')
(>=1.7) (default 'clangScanBuildReports')
Example:
Full Example:
.. literalinclude:: /../../tests/publishers/fixtures/scan-build001.yaml
.. literalinclude:: /../../tests/publishers/fixtures/scan-build-full.yaml
:language: yaml
Minimal Example:
.. literalinclude::
/../../tests/publishers/fixtures/scan-build-minimal.yaml
:language: yaml
"""
threshold = str(data.get('threshold', 0))
if not threshold.isdigit():
raise JenkinsJobsException("Invalid value '%s' for threshold. "
"Numeric value expected." % threshold)
p = XML.SubElement(
xml_parent,
'jenkins.plugins.clangscanbuild.publisher.ClangScanBuildPublisher')
p.set('plugin', 'clang-scanbuild')
XML.SubElement(p, 'markBuildUnstableWhenThresholdIsExceeded').text = \
str(data.get('mark-unstable', False)).lower()
XML.SubElement(p, 'bugThreshold').text = threshold
XML.SubElement(p, 'clangexcludedpaths').text = str(
data.get('exclude-paths', ''))
XML.SubElement(p, 'reportFolderName').text = str(
data.get('report-folder', 'clangScanBuildReports'))
mappings = [
('mark-unstable', 'markBuildUnstableWhenThresholdIsExceeded', False),
('threshold', 'bugThreshold', 0),
('exclude-paths', 'clangexcludedpaths', ''),
('report-folder', 'reportFolderName', 'clangScanBuildReports'),
]
helpers.convert_mapping_to_xml(p, data, mappings, fail_required=True)
def dry(parser, xml_parent, data):

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<builders>
<jenkins.plugins.clangscanbuild.ClangScanBuildBuilder plugin="clang-scanbuild">
<target>path/to/target</target>
<targetSdk>iphonesimulator</targetSdk>
<config>Debug</config>
<clangInstallationName>Analyzer</clangInstallationName>
<xcodeProjectSubPath>myProj/subfolder</xcodeProjectSubPath>
<workspace>workspace</workspace>
<scheme>SchemeName</scheme>
<scanbuildargs>--use-analyzer Xcode</scanbuildargs>
<xcodebuildargs>-derivedDataPath $WORKSPACE/build</xcodebuildargs>
<outputFolderName>clangScanBuildReports</outputFolderName>
</jenkins.plugins.clangscanbuild.ClangScanBuildBuilder>
</builders>
</project>

View File

@ -0,0 +1,12 @@
builders:
- scan-build:
target: path/to/target
target-sdk: iphonesimulator
config: Debug
clang-install-name: Analyzer
xcode-sub-path: myProj/subfolder
workspace: workspace
scheme: SchemeName
scan-build-args: --use-analyzer Xcode
xcode-build-args: -derivedDataPath $WORKSPACE/build
report-folder: clangScanBuildReports

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<builders>
<jenkins.plugins.clangscanbuild.ClangScanBuildBuilder plugin="clang-scanbuild">
<target>path/to/target</target>
<targetSdk>iphonesimulator</targetSdk>
<config>Debug</config>
<clangInstallationName/>
<xcodeProjectSubPath>myProj/subfolder</xcodeProjectSubPath>
<workspace/>
<scheme/>
<scanbuildargs>--use-analyzer Xcode</scanbuildargs>
<xcodebuildargs>-derivedDataPath $WORKSPACE/build</xcodebuildargs>
<outputFolderName>clangScanBuildReports</outputFolderName>
</jenkins.plugins.clangscanbuild.ClangScanBuildBuilder>
</builders>
</project>

View File

@ -0,0 +1,3 @@
builders:
- scan-build:
target: path/to/target

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<publishers>
<jenkins.plugins.clangscanbuild.publisher.ClangScanBuildPublisher plugin="clang-scanbuild">
<markBuildUnstableWhenThresholdIsExceeded>true</markBuildUnstableWhenThresholdIsExceeded>
<bugThreshold>50</bugThreshold>
<clangexcludedpaths>external-lib</clangexcludedpaths>
<reportFolderName>scan-build-report</reportFolderName>
</jenkins.plugins.clangscanbuild.publisher.ClangScanBuildPublisher>
</publishers>
</project>

View File

@ -0,0 +1,6 @@
publishers:
- scan-build:
mark-unstable: true
threshold: 50
exclude-paths: external-lib
report-folder: scan-build-report

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<publishers>
<jenkins.plugins.clangscanbuild.publisher.ClangScanBuildPublisher>
<jenkins.plugins.clangscanbuild.publisher.ClangScanBuildPublisher plugin="clang-scanbuild">
<markBuildUnstableWhenThresholdIsExceeded>false</markBuildUnstableWhenThresholdIsExceeded>
<bugThreshold>0</bugThreshold>
<clangexcludedpaths/>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<publishers>
<jenkins.plugins.clangscanbuild.publisher.ClangScanBuildPublisher>
<jenkins.plugins.clangscanbuild.publisher.ClangScanBuildPublisher plugin="clang-scanbuild">
<markBuildUnstableWhenThresholdIsExceeded>true</markBuildUnstableWhenThresholdIsExceeded>
<bugThreshold>0</bugThreshold>
<clangexcludedpaths>external-lib</clangexcludedpaths>