Start here

Home
About Klocwork
What's new
Fixed issues
Release notes
Installation

Reference

C/C++ checkers
Java checkers
C# checkers
MISRA C 2004 checkers
MISRA C++ 2008 checkers
MISRA C 2012 checkers
MISRA C 2012 checkers with Amendment 1
Commands
Metrics
Troubleshooting
Reference

Product components

C/C++ Integration build analysis
Java Integration build analysis
Desktop analysis
Refactoring
Klocwork Static Code Analysis
Klocwork Code Review
Structure101
Tuning
Custom checkers

Coding environments

Visual Studio
Eclipse for C/C++
Eclipse for Java
IntelliJ IDEA
Other

Administration

Project configuration
Build configuration
Administration
Analysis performance
Server performance
Security/permissions
Licensing
Klocwork Static Code Analysis Web API
Klocwork Code Review Web API

Community

View help online
Visit RogueWave.com
Klocwork Support
Rogue Wave Videos

Legal

Legal information

TeamCity quick start guide

TeamCity is a commercial build server application that provides continuous integration, reporting, and parallel software builds. You can integrate your Klocwork analysis build with a TeamCity server to combine each of these features with your Klocwork analysis.

This example assumes that you have already created a TeamCity project and that you may or may not have active build configurations.

Each TeamCity build configuration defines the settings for your build. This includes the build step, which defines the build runner type, along with build file path information, project information, build triggers, failure conditions and build parameters. For more information about creating your build configuration, refer to the TeamCity documentation.

Create your project/build configuration

If you haven't already, create your project in TeamCity. Next, create your build configuration as you normally would, taking care to specify the details of your build. Then, as part of your build configuration, you must perform the following step:

  1. In the left panel, click Version Control Settings, then under Checkout Options, select Automatically on agent (if supported by VCS roots) from the VCS checkout mode drop-down.

Enable Klocwork Static Analysis on your project

TeamCity uses build agents to perform build operations. You can use multiple build agents to perform many builds in parallel. The build agent typically checks out the source code, initializes the build environment, and runs the software build. You must configure each build agent that will be used to perform Klocwork analysis. The Klocwork Static Analysis build step automatically wraps your existing build steps with the necessary commands to run analysis. The analysis step itself has an option to ignore build steps if you do not want those steps included.

  1. In TeamCity, access your projects list and select the project you want to configure. From here, click Edit Settings
  2. Click Build Steps
  3. Click the Add Build Step button and choose Klocwork Static Analysis as the runner type.
  4. Fill in the Klocwork Server information. The server doesn't have to be on the local machine. The Klocwork Server needs to be specified for the build configuration. It contacts the Klocwork Server to obtain the project configuration for analysis.
  5. Next, click Authorize and log in as any user who is able to view the project. The project needs to exist on both the TeamCity server and on the Klocwork Server. If the project name differs, specify this here as well.

  6. Next you can set up any relevant build failure conditions. You can configure the build to fail if the static analysis is incomplete or create a regular expression to capture any number of failure scenarios. By default, the CI build will fail if any issues are detected. Below is an image which shows the fully configured build step:

You can synchronize custom checkers from your server to your TeamCity build agents by using kwdeploy. The kwdeploy executable can be found on your build agents in the following location: <teamcity_build_agent_root>\tools\klocwork\<platform>\bin\kwdeploy.exe

For example:

<teamcity_build_agent_root>\tools\klocwork\windows\bin\kwdeploy sync --url http(s)://<Klocwork_host>:<port>

Enable build failure

If you want your builds to fail when any new defects are found, you can add a build parameter in TeamCity that will mark a build as failed if defects are discovered during analysis. The following image shows an example of TeamCity configured to fail the build if the JSON file includes one or more new issues. The detected issues will include any new issues since the last build and the issues from all failed builds since the last successful build. If you choose not to fail the build, then the issue list will contain only the issues detected in the latest build.

Run a build and verify the results in Klocwork

You can verify your integration by running a build and checking the JSON output in TeamCity:

A new build is created each time Klocwork performs an analysis.
Note: The first analysis run sets the baseline and therefore no results are shown. New and fixed issues are shown for subsequent builds.
Additional steps are required to access your issues in one of our supported IDEs, as follows:
  • The IDE must be started already
  • The Klocwork desktop analysis plug-in must be installed
  • The relevant project must be open
  • The file containing the issue cannot be modified since the last analysis
In addition to this, Eclipse and Klocwork Desktop require that local analysis must be run once before importing any issues (this must be done every time the project is opened).
Note: When citing issues, if there is a local issue that maps to the same defect as the imported one, the citing information is not merged. Citing a server issue modifies the status on the server only; the citing information is updated after the next CI build.