Plugin Information |
---|
View Clang Scan-Build on the plugin site for more information. |
This plugin allows you to execute Clang scan-build against Mac or iPhone XCode projects or other scan-build compatible build tools.
Description
This plugin allows you configure a build step that will execute the Clang scan-build static analysis tool against an XCode project. This plugin also provides a Post-build Action that will archive the HTML reports and generate a trend graph.
The following features are provided by this plug-in:
- Clang tool installations so you can configure locations differently on slaves
- Clang scan-build build step which allows you to provide XCode settings such as: target, SDK, & configuration
- Dashboard trend chart which details the bug count over time visible on your job's dashboard page
- New bugs since the last build are highlighted so they are easy to identify
- A publisher which will archive the scan-build HTML reports and will optionally fail the build if the bug count exceeds the configured threshold
Please use the mailing lists or issue tracker to ask questions, create feature request, or create bug reports.
Installation
- First install Clang scan-build onto the Jenkins master or slave which will be executing your XCode builds. You can download clang at the following url: http://clang-analyzer.llvm.org/installation.html
- Setup a Clang scan-build installation in the Jenkins main configuration. (Manage Jenkins). You should give your installation a unique name and provide a path to the scan-build folder unless your master will never execute Clang scan-build jobs.
- Edit your Job configuration by adding a 'Clang scan-build' Build Step.
- Choose the installation you wish to use (likely the one you just added).
- Provide the appropriate XCode build settings (target, SDK, & configuration).
Sample job using make
- To invoke scan-build from the command-line using make, create a job with Build Step - Execute Shell such as:
make clean rm -rf ${WORKSPACE}/clangScanBuildReports scan-build -o ${WORKSPACE}/clangScanBuildReports -v -v --use-cc clang --use-analyzer=/usr/bin/clang make
- If you wish to have results published, add the Post-build Action - Publish Clang scan-build reports.
Changelog
Release 1.7
- JENKINS-18941 allow specifying output directory for scan-build reports
- JENKINS-31679 fix logging
Release 1.6
- Remove obsolete "-activetarget" flag (JENKINS-23008)
- Fix null pointer exception in getClangexcludedpaths (JENKINS-28130)
Release 1.5
- Update to Jenkins core parent dependency to 1.580.1
- Change minimum isApplicable() level to AbstractProject, for compatibility with inheritance plugin.
- Add support for clang static analyzer >= 270
- Add the ability to exclude files from scan-build analysis.
- Update the publisher to copy all available reports.
- Remove hardcoded "Xcode 4".
- Add default arguments for xcodebuild and scan-build.
- Update e-mail address for Josh Kennedy.
Release 1.4
- Added code to implement JENKINS-15902 - xcode build arguments can now be specified. They will be added to the end of the command.
Release 1.3.1
- Fixed JENKINS-9251 - If you are using a master/slave configuration the clang scan-build tool home can now be left blank on the master and configured on each slave.
- Fixed another bug which was causing a 500 error when saving the scan-build tool configuration.
Release 1.3
- Merged patch provided by github user 'tru' which passes Jenkins environment variables through the plugin and makes them available to scan-build. This enables passing down variables such as BUILD_NUMBER and other Jenkins environment variables.
- Added the ability to provide arbitrary arguments in the build action configuration which are passed to scan-build.
Release 1.2
- Patch provided by Kenji21 to fix a bug when building on a slave.
- Bug reports are now created on the slave and copied to the master so that they are accessible in your browser
Release 1.1
- Support for X-Code 4
Release 1.0
- Initial Release
- Clang scan-build build step
- Clang scan-build report publisher
- Supports XCode projects within workspace subfolders
25 Comments
Sumeet Garg
I am trying to use this plugin. Has this plugin been written with the intention that the job is executed on the server itself and not a slave machine. The plugin fails while copying clang reports. Error Message - "Unable to copy Clan scan-build output to build archive folder".
Josh Kennedy
I just submitted a new version which includes a patch from Kenji21 for building on slaves. Please test it and let me know if you have any issues.
Huang JYunYu
Hi !
I have the same issue - error message - "FATAL: Unable to copy Clan scan-build output to build archive folder."
Environment:
OS - Ubuntu 14.04
Jenkins - 1.562
Clang Scan-Build Plugin - 1.4
Dave Pete
I'm not very clear on how to setup your plugin using a slave mac machine. For instance, I have jenkins running on Linux and it connects to a mac machine as node (slave). The plugin is forcing me to add the installation directory of the build in the Configure System area of Jenkins (if i tried to add at the node level it only allows drop-down selection of already added clang installations before being able to override main configuration of clang installation). The problem is that it is looking for the location of the clang build on the Jenkins server not on the mac slave, thus erroring out because it cannot find the location of the "scan-build". Am I missing something obvious here? Thanks for any help on this.
Markus Dieterle
Same problem here, probably a bug? :
Master jenkins config (a Linux server): I have to specify at least one installation on master. Name and directory.
This name must be entered within job on master.
Node slave config (a Mac): I add a 'Tool Location', chose tool 'Clan Static Analyzer' with name, specified above in master. Under Home I provide clang-direcotry on slave.
Problem: job that is executed on slave, fails because directory of master is used! :(
Message:
Building remotely on xxxx iOS
...
FATAL: Unable to locate 'scan-build' within 'direcotry of master!!' as configured in clang installation named 'CLANG ch-258' in the master config.
Josh Kennedy
This doesn't sound right. I have used the plugin in a master(windows) - slave(mac) environment without any issues. I believe the error message you are getting is just poorly worded. When it refers to 'master' I think it really means 'global' not the actual master config. When you enter the clang scan-build path on the slave config does it show any errors?
>>> Never mind, just tested it with a linux master and OSX slave. Something must have changed in Jenkins core because I have tested this before...just not recently. I added code to convert scan-build tool installations to node specific installations. It worked great on my configuration. You can leave the masters home path blank and specify paths only on your slaves.
Josh Kennedy
Install version 1.3.1 once it hits the update center. I have added code to convert tool installations to node specific paths.
Markus Dieterle
Perfect, the problem is solved :)
Big thanks!
Steve Jein
Would anyone able to provide an example of how to configure the parameters required by Clang Scan-Build, please? I've spent quite some time researching what information it wants, and now that it appears to be running okay, I get the following error message: "Could not locate a unique scan-build output folder in: Jenkins/build_agent/workspace/MyTestApp/clangScanBuildReports" (-:
I'm not confident that my parameters are correct. Here's what I've got so far:
This is what I get at the end of my build log (Clang Scan-Build is the final step):
Thanks in advance for any suggestions!Josh Kennedy
It looks like the plugin is looking for the scan-build output in Jenkins/build_agent/workspace/Approx/clangScanBuildReports but scan-build put the output in /var/folders/q3/3zqvzkrs17x5gq0cpj23j0gr0000gn/T/scan-build-2011-12-22-1. Are you running this on a master->slave setup?
Paul Eipper
I have the same problem and I am running on a master only setup. How do I setup it to look in the right output folder?
Paul Eipper
I was running version 1.2 of the plugin, 1.3.1 fixed it.
Greg horvath
The plugin is OK -- easy to set up. However, there appear to be some bugs in the scan-build tool, and not having the ability to explicitly pass options to the tool via the plugin is a severe limitation. Please upgrade the plugin to allow configuration flags to be set in the job config and passed directly to the scan-build tool.
Josh Kennedy
I added this feature in version 1.3 which should hit the update center sometime today.
Paul Eipper
Seems it is not compatiple with xcodebuild 4.3, specifically, the activetarget option:
Neil Davis
Works fine with xcodebuild 4.3.1 for me, although I'm specifying a workspace & scheme rather than a project, so maybe that is a way forward for people with this problem?
Paul Eipper
Defining a target seems to work, sort of, now I am having trouble with another flag, this time on the clang invocation:
fabs fabs
Works fine for small projects but I get an out of memory exception on a bigger one with about 120 classes
I increased memory but it didn't help
It crashes when "Publishing Clang scan-build results"
Anurag Bhatnagar
"Could not locate a unique scan-build output folder" for me too.
Deleting '/Users/jenkins/jenkinsnode/workspace/CookScan-ClangAnalyzer/clangScanBuildReports' contents from previous build.
EXECUTING COMMAND:/Users/jenkins/clang/scan-build, -k, -v, -v, -o, /Users/jenkins/jenkinsnode/workspace/CookScan-ClangAnalyzer/clangScanBuildReports, --use-cc=/Applications/Xcode.app/Contents/Developer/toolchains/XcodeDefault.Xctoolchain/usr/bin/Clang, -arch, i386, xcodebuild, -target, CookScan, -configuration, Debug, -sdk, iphonesimulator, clean, build
CookScan-ClangAnalyzer $ /Users/jenkins/clang/scan-build -k -v -v -o /Users/jenkins/jenkinsnode/workspace/CookScan-ClangAnalyzer/clangScanBuildReports --use-cc=/Applications/Xcode.app/Contents/Developer/toolchains/XcodeDefault.Xctoolchain/usr/bin/Clang -arch i386 xcodebuild -target CookScan -configuration Debug -sdk iphonesimulator clean build
scan-build: unrecognized option '-arch'
XCODEBUILD SUCCESS
Publishing Clang scan-build results
Could not locate a unique scan-build output folder in: /Users/jenkins/jenkinsnode/workspace/CookScan-ClangAnalyzer/clangScanBuildReports
Finished: SUCCESS
Any ideas?
Nicolas Zurini
I have 2 problems with Jenkins running Clang plugin:
1/ The generated CLANG report cannot be accessed: http://localhost:8080/job/TestJenkinsApp/97/clangScanBuildBugs/browse/report-WPNzCd.html#EndPath (Status Code 404)
Build is ok.
Clang is executed with this generated command line:/Users/Shared/Jenkins/CLANG/checker-272/scan-build -k -v -v -o /Users/Shared/Jenkins/Home/workspace/TestJenkinsApp/clangScanBuildReports -o clangScanBuildReports xcodebuild -target TestJenkinsApp -configuration Release -sdk iphoneos clean build_> How can I modify my settings to be able to display the details of my scan results?_
2/ My sample App has 2 classes in my projet "TestJenkinsApp":
- root / AppDelegate
- root / TestJenkinsApp / ViewController
note: "root" is the folder containing the xcodeproj file.
> Why Clang only reports errors in AppDelegate even though there are errors in TestJenkinsApp/ViewController too ?
Thanks
matt m
I see your first problem as well.
Jay Graves
#1 is currently being tracked as an issue. https://issues.jenkins-ci.org/browse/JENKINS-17092
Amr S
Hi All,
Can any one give example how configure Jenkins to execute Clang Scan Step.
Here is how it looks like
& this is the error I get
__________________________________________EXECUTING COMMAND:/Users/xxx/Tools/checker-276/scan-build, -k, -v, -v, -o, /Users/Shared/Jenkins/Home/jobs/WiShare/workspace/clangScanBuildReports, xcodebuild, -target, 5.0, -configuration, Debug, -sdk, iphonesimulator, clean, build
workspace $ /Users/xxx/Tools/checker-276/scan-build -k -v -v -o /Users/Shared/Jenkins/Home/jobs/WiShare/workspace/clangScanBuildReports xcodebuild -target 5.0 -configuration Debug -sdk iphonesimulator clean build
scan-build: Using '/Users/xxx/Tools/checker-276/bin/clang' for static analysis
scan-build: Emitting reports for this run to '/Users/Shared/Jenkins/Home/jobs/WiShare/workspace/clangScanBuildReports/2014-04-20-140334-2054-1'.
User defaults from command line:
PBXBuildsContinueAfterErrors = YES
Build settings from command line:
CLANG_ANALYZER_EXEC = /Users/xxx/Tools/checker-276/bin/clang
CLANG_ANALYZER_OTHER_FLAGS =
CLANG_ANALYZER_OUTPUT = plist-html
CLANG_ANALYZER_OUTPUT_DIR = /Users/Shared/Jenkins/Home/jobs/WiShare/workspace/clangScanBuildReports/2014-04-20-140334-2054-1
RUN_CLANG_STATIC_ANALYZER = YES
SDKROOT = iphonesimulator7.1
xcodebuild: error: The project 'WiShare.xcodeproj' does not contain a target named '5.0'.
scan-build: Removing directory '/Users/Shared/Jenkins/Home/jobs/WiShare/workspace/clangScanBuildReports/2014-04-20-140334-2054-1' because it contains no reports.
scan-build: No bugs found.
XCODEBUILD ERROR
Build step 'Clang Scan-Build' marked build as failure
Build step 'Upload to Testflight' marked build as failure__________________________________________
I use Jenkins ver. 1.559 & Xcode Version 5.1.1 (5B1008) & the builds were going successfully before adding the clang step.
Regards,
Amr
Kent Granström
Trying to get this plugin to work in a multi-configuration job but none of the Build-step/Post-build step shows up. Shouldn't it be possible to use it in a multi configuration job? Perhaps I'm just missing something obvious...
By the way. It is possible to select those steps in a freestyle job....
Regards
Travis Bader
Thank you for providing this plugin. It is very useful and I found it very easy to get it working. I have a feature request. I would like to have a setting added so I can choose the location of the clangScanBuildReports. All other post build plugins I use allow for this and being restricted to locating at the root of the workspace complicates our setup quite a bit. Thanks!