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

Jenkins quick start

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

Prerequisites
  • The Klocwork Server needs to be installed and started
  • Project configuration needs to be configured for the build

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

Each Jenkins build configuration defines the settings for your build. This includes the build step(s), 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 Jenkins documentation.
Note: The first analysis run sets the baseline and therefore no results are shown. New and fixed issues are shown for subsequent builds.

Create your project/build configuration

If you haven't already, create your job(s) in Jenkins. Next, create your build configuration as you normally would, taking care to specify the details of your build.

Enable Klocwork Static Analysis on your project

In order to enable Static Analysis on your project, you need to enable the build wrapper for kwinject and add a Klocwork build step to perform the analysis. Jenkins uses slave agents to perform build operations. You can use multiple slave 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 slave 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.
Note: Klocwork Analysis only works with Freestyle Projects.
  1. In Jenkins, access your jobs list and select the project you want to configure. From here, click Configure
  2. Scroll down to the section labeled Build Environment
  3. Click the box labeled Klocwork build wrapper to enable kwinject. If you'd like to configure additional settings for kwinject, click Advanced and enter additional arguments as required.
  4. In order to enable Klocwork Analysis for your project, add a build step called Perform Klocwork Analysis.
  5. In the Klocwork Tools Configuration section, fill out your server and project information. The server doesn't have to be on the local machine. The Klocwork Server URL needs to be specified for the build configuration in order to obtain the project configuration for analysis. Ensure that you use the exact name of the project as specified on the Klocwork Server. You can also enable or disable build steps that are wrapped by kwinject.
    Note: If you change the sequence of the build steps, you need to make sure that you clear all of the build steps wrapped by kwinject and select them in the order that you want them to be executed in.
  6. Next, click Advanced Klocwork Settings... and log in as any user who is able to view the project.

  7. (Optional) Specify the details of your license host. This only needs to be specified if you want to use a different license server than the one configured on the Klocwork Server.
  8. 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.
  9. To view the Klocwork analysis results, edit your project configuration and select the post-build action called Publish Klocwork Static Analysis. Save the configuration, and you can now see a Klocwork Static Analysis link in the left menu. After each build, you can see the analysis results by accessing this link or from the build results page.
    Important: If you make any changes, you need to save and re-open the configuration page for the changes to take affect.

You can synchronize custom checkers from your server to your Jenkins slaves by using kwdeploy. The kwdeploy executable can be found on your slaves in the following location: <Remote root directory>\klocwork\tools\bin\kwdeploy

For example:

<Remote root directory>\klocwork\tools\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 Jenkins that will mark a build as failed if defects are discovered during analysis. The following image shows an example of Jenkins 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 Jenkins. The button allows you to open the issue in an IDE you have open on your machine.

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.

Log in and cite issues

The login dialog found on the project status page in Jenkins allows you to verify your user account against the Klocwork Server. If that user exists on the Klocwork Server, this allows you to retrieve issue details such as traceback and line number from the server. Also, logging in enables an edit button next to each issue found in your latest CI build which allows you to cite the status of an issue and add comments.
Note: After you cite an issue, the change is not applied until your next CI build. For example, if you set an issue to the status 'Not a problem', you will see it in your issue list within Jenkins until the next build is performed.