Child pages
  • Clang Scan-Build Plugin
Skip to end of metadata
Go to start of metadata

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.


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.


  • 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:
  • 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.


Release 1.7

Release 1.6

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


  1. 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".

    1. 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.

      1. Hi !  

        I have the same issue - error message - "FATAL: Unable to copy Clan scan-build output to build archive folder."


        OS - Ubuntu 14.04

        Jenkins - 1.562

        Clang Scan-Build Plugin - 1.4

  2. 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. 

    1. 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! :(

      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.

      1. 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.

    2. Install version 1.3.1 once it hits the update center.  I have added code to convert tool installations to node specific paths.

      1. Perfect, the problem is solved :)

        Big thanks!

  3. 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:

    • Target: (the name of my iPhone app) "MyTestApp"
    • Xcode 4 workspace: (blank)
    • Xcode 4 scheme: (blank)
    • Target SDK: "iphonesimulator"
    • Clan scan-build configuration (defined under Jenkins Configure System): "Clang 258"
    • Build Configuration: "Debug"Xcode project sub-path: (blank)

    This is what I get at the end of my build log (Clang Scan-Build is the final step):

    scan-build: 1 bugs found.
    scan-build: Run 'scan-view /var/folders/q3/3zqvzkrs17x5gq0cpj23j0gr0000gn/T/scan-build-2011-12-22-1' to examine bug reports.
    Publishing Clang scan-build results
    Could not locate a unique scan-build output folder in: Jenkins/build_agent/workspace/Approx/clangScanBuildReports

    Thanks in advance for any suggestions!

    1. 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?

      1. 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?

        1. I was running version 1.2 of the plugin, 1.3.1 fixed it.

  4. 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.

    1. I added this feature in version 1.3 which should hit the update center sometime today.

  5. Seems it is not compatiple with xcodebuild 4.3, specifically, the activetarget option:

    xcodebuild: error: option '-activetarget' is no longer supported
    Usage: xcodebuild [-project <projectname>] [[-target <targetname>]...|-alltargets] [-configuration <configurationname>] [-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]] [<buildsetting>=<value>]... [<buildaction>]...
           xcodebuild [-project <projectname>] -scheme <schemeName> [-configuration <configurationname>] [-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]] [<buildsetting>=<value>]... [<buildaction>]...
           xcodebuild -workspace <workspacename> -scheme <schemeName> [-configuration <configurationname>] [-arch <architecture>]... [-sdk [<sdkname>|<sdkpath>]] [<buildsetting>=<value>]... [<buildaction>]...
           xcodebuild -version [-sdk [<sdkfullpath>|<sdkname>] [<infoitem>] ]
           xcodebuild -list [[-project <projectname>]|[-workspace <workspacename>]]
           xcodebuild -showsdks
        -usage                print full usage
        -verbose              provide additional status output
        -license              Show License agreement!
        -project NAME         build the project NAME
        -target NAME          build the target NAME
        -alltargets           build all targets
        -workspace NAME       build the workspace NAME
        -scheme NAME          build the scheme NAME
        -configuration NAME   use the build configuration NAME for building each target
        -xcconfig PATH        apply the build settings defined in the file at PATH as overrides
        -arch ARCH            build each target for the architecture ARCH; this will override architectures defined in the project
        -sdk SDK              use SDK as the name or path of the base SDK when building the project
        -parallelizeTargets   build independent targets in parallel
        -jobs NUMBER          specify the maximum number of concurrent build operations
        -showsdks             display a compact list of the installed SDKs
        -list                 lists the targets and configurations in a project, or the schemes in a workspace
        -find BINARY          display the full path to BINARY in the provided SDK
        -version              display the version of Xcode; with -sdk will display info about one or all installed SDKs
    scan-build: Removing directory '/var/folders/cm/trkrrrr96kb20n_n5k2mzqd40000gn/T/scan-build-2012-03-06-1' because it contains no reports.
    Build step 'Clang Scan-Build' marked build as failure
    1. 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?

  6. Defining a target seems to work, sort of, now I am having trouble with another flag, this time on the clang invocation:

    clang: error: unsupported option '--serialize-diagnostics'
  7. 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"

  8. "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/, -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/ -arch i386 xcodebuild -target CookScan -configuration Debug -sdk iphonesimulator clean build
    scan-build: unrecognized option '-arch'
    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?

  9. 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 ?


    1. I see your first problem as well.

  10. 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_OUTPUT = plist-html
    CLANG_ANALYZER_OUTPUT_DIR = /Users/Shared/Jenkins/Home/jobs/WiShare/workspace/clangScanBuildReports/2014-04-20-140334-2054-1
    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.
    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.



  11. 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....


  12. 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!