summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKien Ha <kienha9922@gmail.com>2016-07-11 11:25:11 -0400
committerKien Ha <kienha9922@gmail.com>2016-07-11 17:50:50 -0400
commit99e6b5f89c23bc9d0973f02ece02d7fbbf5452c9 (patch)
tree0f14583b136ae043681bd3b1529458725dc530c2
parentd6add35e72c6c2beb44b1be57f589d79f98f5551 (diff)
downloadpython-jenkins-job-builder-99e6b5f89c23bc9d0973f02ece02d7fbbf5452c9.tar.gz
python-jenkins-job-builder-99e6b5f89c23bc9d0973f02ece02d7fbbf5452c9.tar.xz
python-jenkins-job-builder-99e6b5f89c23bc9d0973f02ece02d7fbbf5452c9.zip
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>
-rw-r--r--jenkins_jobs/modules/builders.py63
-rw-r--r--jenkins_jobs/modules/publishers.py34
-rw-r--r--tests/builders/fixtures/scan-build-full.xml17
-rw-r--r--tests/builders/fixtures/scan-build-full.yaml12
-rw-r--r--tests/builders/fixtures/scan-build-minimal.xml17
-rw-r--r--tests/builders/fixtures/scan-build-minimal.yaml3
-rw-r--r--tests/publishers/fixtures/scan-build-full.xml11
-rw-r--r--tests/publishers/fixtures/scan-build-full.yaml6
-rw-r--r--tests/publishers/fixtures/scan-build-minimal.xml (renamed from tests/publishers/fixtures/scan-build002.xml)2
-rw-r--r--tests/publishers/fixtures/scan-build-minimal.yaml (renamed from tests/publishers/fixtures/scan-build002.yaml)0
-rw-r--r--tests/publishers/fixtures/scan-build001.xml2
11 files changed, 149 insertions, 18 deletions
diff --git a/jenkins_jobs/modules/builders.py b/jenkins_jobs/modules/builders.py
index 2d61c811..b54d3547 100644
--- a/jenkins_jobs/modules/builders.py
+++ b/jenkins_jobs/modules/builders.py
@@ -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
diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py
index 1a583bfa..2e71e5dc 100644
--- a/jenkins_jobs/modules/publishers.py
+++ b/jenkins_jobs/modules/publishers.py
@@ -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
- """
- threshold = str(data.get('threshold', 0))
- if not threshold.isdigit():
- raise JenkinsJobsException("Invalid value '%s' for threshold. "
- "Numeric value expected." % threshold)
+ Minimal Example:
+
+ .. literalinclude::
+ /../../tests/publishers/fixtures/scan-build-minimal.yaml
+ :language: yaml
+ """
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):
diff --git a/tests/builders/fixtures/scan-build-full.xml b/tests/builders/fixtures/scan-build-full.xml
new file mode 100644
index 00000000..244a50f6
--- /dev/null
+++ b/tests/builders/fixtures/scan-build-full.xml
@@ -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>
diff --git a/tests/builders/fixtures/scan-build-full.yaml b/tests/builders/fixtures/scan-build-full.yaml
new file mode 100644
index 00000000..3889fd58
--- /dev/null
+++ b/tests/builders/fixtures/scan-build-full.yaml
@@ -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
diff --git a/tests/builders/fixtures/scan-build-minimal.xml b/tests/builders/fixtures/scan-build-minimal.xml
new file mode 100644
index 00000000..87ab245a
--- /dev/null
+++ b/tests/builders/fixtures/scan-build-minimal.xml
@@ -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>
diff --git a/tests/builders/fixtures/scan-build-minimal.yaml b/tests/builders/fixtures/scan-build-minimal.yaml
new file mode 100644
index 00000000..a7da720b
--- /dev/null
+++ b/tests/builders/fixtures/scan-build-minimal.yaml
@@ -0,0 +1,3 @@
+builders:
+ - scan-build:
+ target: path/to/target
diff --git a/tests/publishers/fixtures/scan-build-full.xml b/tests/publishers/fixtures/scan-build-full.xml
new file mode 100644
index 00000000..e6806e9a
--- /dev/null
+++ b/tests/publishers/fixtures/scan-build-full.xml
@@ -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>
diff --git a/tests/publishers/fixtures/scan-build-full.yaml b/tests/publishers/fixtures/scan-build-full.yaml
new file mode 100644
index 00000000..884e6c65
--- /dev/null
+++ b/tests/publishers/fixtures/scan-build-full.yaml
@@ -0,0 +1,6 @@
+publishers:
+ - scan-build:
+ mark-unstable: true
+ threshold: 50
+ exclude-paths: external-lib
+ report-folder: scan-build-report
diff --git a/tests/publishers/fixtures/scan-build002.xml b/tests/publishers/fixtures/scan-build-minimal.xml
index efd1d8c5..161cb5ee 100644
--- a/tests/publishers/fixtures/scan-build002.xml
+++ b/tests/publishers/fixtures/scan-build-minimal.xml
@@ -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/>
diff --git a/tests/publishers/fixtures/scan-build002.yaml b/tests/publishers/fixtures/scan-build-minimal.yaml
index 6b0d6c6a..6b0d6c6a 100644
--- a/tests/publishers/fixtures/scan-build002.yaml
+++ b/tests/publishers/fixtures/scan-build-minimal.yaml
diff --git a/tests/publishers/fixtures/scan-build001.xml b/tests/publishers/fixtures/scan-build001.xml
index 261c5015..d1c9964b 100644
--- a/tests/publishers/fixtures/scan-build001.xml
+++ b/tests/publishers/fixtures/scan-build001.xml
@@ -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>