Jenkins quick start
|In this topic:|
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.
- 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.
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 Jenkins, access your jobs list and select the project you want to configure. From here, click Configure
- Scroll down to the section labeled Build Environment
- 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.
- In order to enable Klocwork Analysis for your project, add a build step called Perform Klocwork Analysis.
- 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.
- Next, click Advanced Klocwork Settings... and log in as any user who is able to view the project.
- (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.
- 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.
- 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
<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 KlocworkYou 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.
- 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