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:
parent
d6add35e72
commit
99e6b5f89c
@ -2546,6 +2546,69 @@ def github_notifier(parser, xml_parent, data):
|
|||||||
'com.cloudbees.jenkins.GitHubSetCommitStatusBuilder')
|
'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):
|
def ssh_builder(parser, xml_parent, data):
|
||||||
"""yaml: ssh-builder
|
"""yaml: ssh-builder
|
||||||
Executes command on remote host
|
Executes command on remote host
|
||||||
|
@ -4665,31 +4665,33 @@ def scan_build(parser, xml_parent, data):
|
|||||||
exceeds a threshold (default false)
|
exceeds a threshold (default false)
|
||||||
:arg int threshold: Threshold for marking builds as unstable (default 0)
|
:arg int threshold: Threshold for marking builds as unstable (default 0)
|
||||||
:arg string exclude-paths: Comma separated paths to exclude from reports
|
: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
|
: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
|
: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(
|
p = XML.SubElement(
|
||||||
xml_parent,
|
xml_parent,
|
||||||
'jenkins.plugins.clangscanbuild.publisher.ClangScanBuildPublisher')
|
'jenkins.plugins.clangscanbuild.publisher.ClangScanBuildPublisher')
|
||||||
|
p.set('plugin', 'clang-scanbuild')
|
||||||
|
|
||||||
XML.SubElement(p, 'markBuildUnstableWhenThresholdIsExceeded').text = \
|
mappings = [
|
||||||
str(data.get('mark-unstable', False)).lower()
|
('mark-unstable', 'markBuildUnstableWhenThresholdIsExceeded', False),
|
||||||
XML.SubElement(p, 'bugThreshold').text = threshold
|
('threshold', 'bugThreshold', 0),
|
||||||
XML.SubElement(p, 'clangexcludedpaths').text = str(
|
('exclude-paths', 'clangexcludedpaths', ''),
|
||||||
data.get('exclude-paths', ''))
|
('report-folder', 'reportFolderName', 'clangScanBuildReports'),
|
||||||
XML.SubElement(p, 'reportFolderName').text = str(
|
]
|
||||||
data.get('report-folder', 'clangScanBuildReports'))
|
helpers.convert_mapping_to_xml(p, data, mappings, fail_required=True)
|
||||||
|
|
||||||
|
|
||||||
def dry(parser, xml_parent, data):
|
def dry(parser, xml_parent, data):
|
||||||
|
17
tests/builders/fixtures/scan-build-full.xml
Normal file
17
tests/builders/fixtures/scan-build-full.xml
Normal 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>
|
12
tests/builders/fixtures/scan-build-full.yaml
Normal file
12
tests/builders/fixtures/scan-build-full.yaml
Normal 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
|
17
tests/builders/fixtures/scan-build-minimal.xml
Normal file
17
tests/builders/fixtures/scan-build-minimal.xml
Normal 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>
|
3
tests/builders/fixtures/scan-build-minimal.yaml
Normal file
3
tests/builders/fixtures/scan-build-minimal.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
builders:
|
||||||
|
- scan-build:
|
||||||
|
target: path/to/target
|
11
tests/publishers/fixtures/scan-build-full.xml
Normal file
11
tests/publishers/fixtures/scan-build-full.xml
Normal 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>
|
6
tests/publishers/fixtures/scan-build-full.yaml
Normal file
6
tests/publishers/fixtures/scan-build-full.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
publishers:
|
||||||
|
- scan-build:
|
||||||
|
mark-unstable: true
|
||||||
|
threshold: 50
|
||||||
|
exclude-paths: external-lib
|
||||||
|
report-folder: scan-build-report
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<jenkins.plugins.clangscanbuild.publisher.ClangScanBuildPublisher>
|
<jenkins.plugins.clangscanbuild.publisher.ClangScanBuildPublisher plugin="clang-scanbuild">
|
||||||
<markBuildUnstableWhenThresholdIsExceeded>false</markBuildUnstableWhenThresholdIsExceeded>
|
<markBuildUnstableWhenThresholdIsExceeded>false</markBuildUnstableWhenThresholdIsExceeded>
|
||||||
<bugThreshold>0</bugThreshold>
|
<bugThreshold>0</bugThreshold>
|
||||||
<clangexcludedpaths/>
|
<clangexcludedpaths/>
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<jenkins.plugins.clangscanbuild.publisher.ClangScanBuildPublisher>
|
<jenkins.plugins.clangscanbuild.publisher.ClangScanBuildPublisher plugin="clang-scanbuild">
|
||||||
<markBuildUnstableWhenThresholdIsExceeded>true</markBuildUnstableWhenThresholdIsExceeded>
|
<markBuildUnstableWhenThresholdIsExceeded>true</markBuildUnstableWhenThresholdIsExceeded>
|
||||||
<bugThreshold>0</bugThreshold>
|
<bugThreshold>0</bugThreshold>
|
||||||
<clangexcludedpaths>external-lib</clangexcludedpaths>
|
<clangexcludedpaths>external-lib</clangexcludedpaths>
|
||||||
|
Loading…
Reference in New Issue
Block a user