KISS

Keep It Simple Stupid

Jenkins Clang Scan-Build plugin: support matrix builds

| comments

I’m using Jenkins to build iOS projects (as you may have noticed from my previous jenkins posts). One of build steps that can help developers is running the Clang scan-build static analyzer and publishing the results. Luckily, there is an existing Clang Scan-Build Jenkins plugin available, however it hasn’t been updated for a while. I stumbled upon Sean Wang’s blog post (https://fclef.wordpress.com/2014/10/11/jenkins-clang-scan-build-plugin-support-for-xcode5-and-later/) describing his fixes for latest Xcode. That’s a great update!

So it worked fine until I needed to use it in a matrix (aka multi-configuration) project. It was missing from the list of available build steps! One solution is to emulate the matrix build by having N regular builds, one for each of the configurations, to run the analyzer, but that would be very painful to maintain.

It turned out to be quite easy to patch the plugin to support matri projects. The source code is available in my fork: https://github.com/eunikolsky/clang-scanbuild-plugin. I have also fixed tests there.

You can either download the patched plugin built by me or build it yourself. The binary is here clang-scanbuild-plugin.hpi and its SHA256SUM is:

1
0c5b12b1cd95c2b66426a5b719c496c5c18d1918cf33ca56a490df17e9b5e6a5  clang-scanbuild-plugin.hpi

To build it you can use these commands:

1
2
3
4
5
6
# install maven if you don't have it
brew install maven

git clone https://github.com/eunikolsky/clang-scanbuild-plugin.git --depth 1
cd clang-scanbuild-plugin/
mvn clean package

You’ll find the clang-scanbuild-plugin.hpi file in the target directory.

To install, go to Manage Jenkins > Manage Plugins > Advanced, select the clang-scanbuild-plugin.hpi file in the Upload Plugin section, and click Upload. Done.

FYI: to install scan-build on OSX without building the whole LLVM and obviously without downloading manually, is to use this command:

1
brew install https://raw.githubusercontent.com/kavu/homebrew/add957837235e4cbb69bc0c752aeca74f760b3e2/Library/Formula/clang-analyzer.rb

Comments