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
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 configurationIf 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 projectIn 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.
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 failureIf 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![]() Additional steps are required to access your issues in one of our supported IDEs, as follows:
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.
|