Child pages
  • Klocwork Community Plugin
Skip to end of metadata
Go to start of metadata

Plugin Information

View Klocwork Community on the plugin site for more information.

This plugin automates Klocwork analyses. For up-to-date documentation please visit the Emenda website: http://emenda.com/jenkins-klocwork-docs

 

 

Maintained by Emenda

Latest features:

  • Pipeline support
  • Job-DSL support
  • Klocwork Cross-Project Synchronisation
  • Incremental Diff Analysis & Quality Gateway

Note on Deprecation in v2.0+

Please note that in v2.0 we added new functionality to the plugin. Instead of updating (and possibly breaking) the old parts of the plugin we added completely new functionality. We will not remove any existing functionality but have marked it as Deprecated and will not actively add new features to it. Instead we recommend that you start using the new features, as detailed in the documentation. We hope that the new features are better and easier for you to use!

Support

Please contact Emenda support for requests or help with the plugin: support@emenda.com

Changelog

Version 2.3.7

  • Minor bug fix: Updated file handling to use UTF-8 to support use in Japan

Version 2.3.6

  • New feature: added an option to the quality gate to stop the build from continuing if the gate failed a condition
  • Major bug fix: fixed backwards compatibility issue with quality gate in pipelines when referring to old config using the terms 'Desktop', when using old config this cause the quality gate to be skipped.

Version 2.3.5

  • Minor bug fix: resolved issue where the quality gate config wouldn't show in job configuration page.

Version 2.3.4

  • New feature: Added in support to use kwciagent as the diff analysis tool
  • Re-factored plug-in to refer to Ci rather than Desktop in the diff analysis
  • Minor bug fix: fixed issue were build command got encapsulated in quotes
  • Added a config file for the pipeline step for the build specification generation step, this enables the step to appear in the syntax generator.

Version 2.3.3

  • Minor bug fix: resolved issue in diff analysis where files/paths were in a different case on windows between the build specification and file system were being ignored.
  • Minor bug fix: resolved issue on windows were the git change list command was incorrectly encapsulating the command with double quotes.

Version 2.3.2

  • Added the Klocwork tools kwgradlew and kwgradle to the drop down selection for the build specification step

Version 2.3.1

  • Minor bug fix: resolved conflict with other plug-ins using older versions of org.joda.time

Version 2.3

  • New feature: added a new step for generating a build specification file to be run before the analysis steps

Version 2.2.3

  • New feature: added an option to the integration build step to disable the running of kwdeploy.

Version 2.2.2

  • Changed how the output from kwcheck was generated to reduce console noise and generate a consistent xml
  • Minor bug fix: Fixed an issue with windows agents were env vars were not injected correctly

Version 2.2.1

  • Minor bug fix: updated deprecated build step to make use build name setting

Version 2.2

  • New feature: support for Java diff analysis
  • Major bug fix: resolved issue were global license server settings were passed to integration analysis step even if blank
  • Major bug fix: updated the integration quality gate query to allow users to specify grouping:on if they wish

Version 2.1

  • Minor bug fix: resolved potential NPD when checking threshold values

  • Minor bug fix: updated the wiki link in the plugin pom.xml
  • Major bug fix: updated Klocwork api library to make use of Jenkins environment variables

Version 2.0

  • Simplified creation of Klocwork static analysis jobs or tasks
  • Supports Klocwork full, incremental and incremental diff analysis
  • Allows job success criteria to be connected to static analysis results via a Quality Gateway
  • Provides per-checkin CI analysis of just the changed files for minimum analysis times
  • Support for Jenkins Pipelines
  • Support for Job-DSL

Version 1.24.6

  • Merged various changes and bug fixes from Emenda
  • Added support for use of variables in configuration
  • Updated the version of kwjlib for Klocwork API usage
  • Updated the global settings so that it uses the Klocwork tool in the path

Version 1.18

* Fix reoponed JENKINS-29673 - Klocwork plugin does not work in a master/slave configuration

Version 1.17

* Fix JENKINS-29673 - Klocwork plugin does not work in a master/slave configuration

Version 1.16.3

* Avoid errors when building on slaves
* Avoid error 500 when restarting jenkins
* Avoid NPE from old version of config.xml which doesn't contain the tag <webAPI>

Version 1.16.2

* Clean code by applying IDEA format and by removing unused code
* Use SCM features for changelog

Version 1.16.1

* Changing Jenkins version to be Java 7 compliant

Version 1.16

* Enabled multiple build specification files
* Removed Dashboard portlet component to also remove dependency on dashboard view plugin
* Added SSL support
* Build graph previously incorrectly removed, now re-instated
* Fixed Multiconfiguration project bug in Publisher

Version 1.15

* Enabled embedded Klocwork results in Klocwork v9.6 and later.
Achieved using kwjlib to retrieve issues from Klocwork Web API, which are
put into an XML file by KloXMLGenerator and then parsed as before

Version 1.14.1

* Allowing Klocwork publisher to appear in maven job

Version 1.14

* Fixed NullPointerException and added compiler options

Version 1.13

* Fix reopened JENKINS-12861 - klocwork - update to recognize 9.5.x xml schema

Version 1.12

* Fix JENKINS-12861 - klocwork - update to recognize 9.5.x xml schema

Version 1.11

* Merge pull request - Add compatibility with Klocwork v9.6

Version 1.10

* Fix JENKINS-13668 - Klocwork Plugin Fails if no KW Issues

Version 1.9

* Fix JENKINS-14005 - Major issue when Klocwork reporting is enabled

Version 1.8.1

* Allow publisher part to appear in maven jobs.

Version 1.8

* Fixed JENKINS-13743 - Jenkins 1.463 + Klocwork plugin - crashes when saving configuration

Version 1.7

* Fixed JENKINS-12535 - Link to the line which contains the klocwork error instead of just linking to the file.

Version 1.6

* Update to latest DTkit versions

Version 1.5

* Updated version number. Provided variable ${BUILD_ID} when specifying Klocwork tables directory such that a unique directory can be used for each build.
* Added functionality to specify options for kwbuildproject. Useful for changing location of tables directory, adding compiler options, etc.

Version 1.4

* Updated xml parser to work with reports generated by Klocwork v9.5. New features: per-build pie chart showing number of issues and their state, a link to view the build.log, link to view the parse_errors.log and a link to access Klocwork Review within Jenkins. Now to test on Windows.

Version 1.3

* Fixed JENKINS-10773
* Fixed JENKINS-10775
* Fixed JENKINS-10776

Version 1.2

* Fixed JENKINS-10455

Version 1.1

* Fixed JENKINS-10379 - Allowed statuses for Klocwork report are incorrect
* Fixed args parsing

Version 1.0

* Initial version

31 Comments

    1. As the KW plugin doesn't seem to be integrated with SA/AC you may need to pull a text report from KW server and use Warnings plugin to get standard visualizations....

      1. Could you fill in a ticket in the Jenkins JIRA?

  1. Hi

    I have seen on github that the issue with new klocwork v9.5 xml files seems to be solved in master branch.

    Is there a new release version planned for the plugin? (I do not feel confident enough to set up the build environment myself.)

    Regards

    /David

    1. Please check with version 1.6

  2. plug-in 1.8 fix the crash saving configuration  but  still have a issue in build kwbuildproject phase .FATAL: command execution failed
    java.io.IOException: Cannot run program "" (in directory "/var/lib/jenkins/jobs/Linux_Kernel_Common_Build/workspace"): java.io.IOException: error=2, No such file or directory

  3. Thanks for the plugin. but I can't find any links to the analysis result page. Do i miss something?

    here is the last part log of one success build:

    
    Loading project database - progress: 100%
    Loading project database - progress: 100%
    Loading project database - progress: 100%
    Tue Jun 12 11:22:44 CST 2012: Database loading stage completed
    Build successfully created.
    [workspace] $ cmd.exe /C '""D:/develop/Klocwork/Server 9.5\bin\kwinspectreport" \--project my_project \--build build_ci_20120612_111355 \--xml "C:\Documents and Settings\Jedi Huang\.jenkins\jobs\test\workspace\klocwork_result.xml" \--host 172.20.38.14 \--port 8100 \--license-host 172.20.38.14 \--license-port 27000 && exit %%ERRORLEVEL%%"'
    Finished: SUCCESS
    
  4. Hi,

    I'm now testing the latest release of Klocwork, version 9.6 and now kwinspectreport do not have the -xml option available.

    So that it's impossible to generate the XML report that will be injected in the Klocwork plugin.

    Are you aware of this situation ? I think they turn to WebAPI technology. But what about the Klocwork plugin now ?

    Regards.

  5. Hi

    How to generate the xml files using kwjlib ? 

    regards

    mithun 

    1. I was wondering the same thing.

      I receive the following error because I don't know how to generate the xml report that the plugin is asking for:

      April 23, 2013 3:41:48 AM EDT: Database loading stage completed
      
      Build successfully created.
      Connecting to Klocwork Web API service
      Creation of XML file complete. Closing connection to Web API.
      Starting the klocwork analysis.
      Parsing has been canceled. No klocwork test report file(s) were found with the pattern 'klocwork_result.xml' relative to 'D:\Jenkins\jobs\Klocwork - Win32\workspace'.  Did you enter a pattern relative to the correct directory?  Did you generate the XML report(s) for Klocwork? No klocwork test report file(s) were found with the pattern 'klocwork_result.xml' relative to 'D:\Jenkins\jobs\Klocwork - Win32\workspace'.  Did you enter a pattern relative to the correct directory?  Did you generate the XML report(s) for Klocwork?
      Build step 'Publish Klocwork test result report' changed build result to FAILURE
      Build step 'Publish Klocwork test result report' marked build as failure
      
  6. Does the plugin support klocwork server configured with SSL. I don't see an option in the configuration.

  7. There is mention of 1.16 with SSL Support, what is the status of this?

  8. I added the --incremental option to kwbuildproject but it always sseems to use --force. Is this by design?

  9. I couldn't find a way to set up the bitbake environment in order to use it with kwinject command.

    I only have to source a file with variables.

    The OS is Ubuntu.

    I have tried with Env Inject variables plugin, with an execute shell field, but the bitbake command is still unknown: kwinject FATAL: can not exec bitbake: No such file or directory

    Can you give me a hint?

  10. Hello Everyone,

    Can anyone suggest me how to invoke the klocwork command from jenkins. As I am new to it,i was looking on it

    Below  are the Steps what I tried:

    Under Build Tab:

    1 Select the invoke klocwork command.

    2 klocwork version:11.2

    3 Project Name :JenkinsTestProject

    4 Build Name : (Optional)

    5 Build using : Build Command

    6 Build Value: kwant

    7 Klocwork Build Option: Left Blank

    I am having doubt in Point number 6, what are all the values that we

     need to pass. It would be great If any link or video can be suggested.

     

    Following are the links which I referred but did not find  much information:

    https://www.youtube.com/watch?v=PJcrnvs0kFo

    http://emenda.com/klocwork-jenkins/

    http://emenda.com/resources/jenkins-klocwork-docs/

    regards,

    Gnyanraj

    1. Hi Gnyanraj (smile),

      May I suggest you contact Emenda support directly via support@emenda.eu, through which support is much more readily available.

      Kind regards,
      Ben
      Emenda Support

  11. I am creating a pipeline using the declarative pipeline flavour, with clockwork steps enclosed within a : klocworkWrapper { .... } Ok, analysis is launched, and I can see the results on the Klocwork server web interface. But I cannot find a way to retrieve resulting diagrams on the Jenkins web interface, even when using the pipeline script generator. Unless I am totally wrong, I think that I should use klocworkQualityGateway, but the generated script snippet is not correct. Once copied within the wrapper, it fails lacking for some enableXYGateway or gatewayXYConfig property.

    For example this line :

    klocworkQualityGateway([enableCiGateway: false, enableServerGateway: true, gatewayServerConfigs: [[conditionName: 'Issues', jobResult: 'failure', query: 'state:+Status,Fix', threshold: '1']]])
    

    fails with an error message :

    WorkflowScript: 92: Missing required parameter: "gatewayCiConfig" @ line 92, column 1.
       klocworkQualityGateway([enableCiGateway: false, enableServerGateway: true, gatewayServerConfigs: [[conditionName: 'Issues', jobResult: 'failure', query: 'state:+Status,Fix', threshold: '1']]])
    

    I really cannot find a way to make it work, and I guess I can take a wrong turn... so any help would be appreciate.

    Thanks for your help and best regards J-L

  12. Ok, let's give more details.
    The configuration is made within a wrapper that looks like :

     

    klocworkWrapper(installConfig: 'My Klocwork', ltoken: "${HOME}/.klocwork/ltoken", serverConfig: 'Klocwork@XYZ', serverProject: 'S3cr3TPr0j3ct') {
        klocworkBuildSpecGeneration([additionalOpts: '', buildCommand: 'make', ignoreErrors: true, output: 'kwinject.out', tool: 'kwinject'])
        klocworkIntegrationStep1([additionalOpts: '', buildSpec: 'kwinject.out', disableKwdeploy: false, ignoreCompileErrors: true, importConfig: '', incrementalAnalysis: false, tablesDir: 'kwtables'])
        klocworkIntegrationStep2([additionalOpts: '', buildName: "${JOB_BASE_NAME}_${BUILD_NUMBER}", tablesDir: 'kwtables'])
    }
    	

     

    This runs correctly and actually publish results on the Klocwork server.

    But, now, I want to publish the results on the Jenkins web interface, and I do not succeed after several trials.
    Now, reading the documentation I found this for Job DSL :

     publishers{
      klocworkGatewayPublisher {
       gatewayConfig {
        enableServerGateway(true)
        gatewayServerConfigs {...} //Server analysis gateway - pass/fail the Jenkins job based on server analysis results
        enableDesktopGateway(true)
        gatewayDesktopConfig {...} //Desktop analysis gateway - pass/fail the Jenkins job based on desktop analysis results
       }
      }
     }

    I gave tried to adapt this for my pipeline, but it always fails due to syntax error or exceptions.
    With :

     
    I get an exception :
    java.lang.NoSuchMethodError: No such DSL method 'klocworkGatewayPublisher' found among steps [ansiColor, archive, bat, build, catchError, checkout, ... etc...

     

    So ... I am a but lost...

    If someone could help,  would greatly appreciate !

    Have a nice day !



    1. Hi Jean-Luc,

      The correct syntax for the gateway step (integration analysis) of the pipeline for the latest version should be:

      klocworkQualityGateway([
      	enableCiGateway: false,
      	enableServerGateway: true,
      	gatewayServerConfigs: [
      							[
      								conditionName: 'Integration Analysis QualityGate', //text name for the condition
      								jobResult: 'unstable', //the job status to set the Jenkins job to when the condition fails
      								query: 'state:+New status:+Analyze,+Fix recommended:on', //search query used to get issues
      								threshold: '1' // >= threshold for number of issues returned from the search query
      							]
      						  ]
      ])
      

      Which we can confirm works with Jenkins 2.60.3 and 2.3.5 of the plug-in. On first glance I cant see anything wrong in your first usage, could you try again with my example? If nothing works could you let us know the version of Jenkins and version of the Klocwork plugin? If you prefer to do this via email please contact us on support@emenda.com

      Best Regards,

      Michael

      Emenda Support

  13. Hi MIchael,

    Thanks a lot for the help.
    In fact, I had continue to search on my own and read again the doc better and found the solution you propose. Never mind, I appreciate your help.

    But now, I am stuck with the publisher.
    As the klocwork plugin does not seem to natively offer a publisher for pipeline, I tried (by analogy with an example I read for Robot) to add this through a script step in the post section, enclosed within the same wrapper configuration as the one for the Klocwork steps, as shown below :

        post {
            always {
    			klocworkWrapper(installConfig: 'My Klocwork', ltoken: "${HOME}/.klocwork/ltoken", serverConfig: 'Klocwork@XYZ', serverProject: 'S3cr3TPr0j3ct') {
                script{
                    
                    step([
                        $class: 'KlocworkGatewayPublisher',
                        gatewayConfig: [
                            enableServerGateway: true,
                            gatewayServerConfigs: [[conditionName: '*default*', jobResult: 'unstable', query: "build:${JOB_BASE_NAME}_${BUILD_NUMBER} status:+Analyze,+Fix", threshold: '1']],
                            enableDesktopGateway: false,
                            gatewayDesktopConfig: [reportFile: '', threshold: '1']
                        ]
                    ]
                   )
                  }
                }
            }
                }
    }

    But this lead to an exception :

    [Pipeline] klocworkWrapper
    00:01:29.255 [Klocwork BuildWrapper] - Setting up environment variables for Klocwork jobs...
    00:01:29.256 [Klocwork BuildWrapper] - Adding the Klocwork Server URL https://<klocwork server @:port
    00:01:29.256 [Klocwork BuildWrapper] - Using specific License for given server XYZ@mycompany.com
    00:01:29.256 [Klocwork BuildWrapper] - Adding Klocwork paths. Using install "My Klocwork"
    00:01:29.256 [Klocwork BuildWrapper] - Detected ltoken file. Setting KLOCWORK_LTOKEN to "/home/jenkins/.klocwork/ltoken"
    [Pipeline] {
    [Pipeline] script
    [Pipeline] {
    [Pipeline] step
    00:01:29.312 [Klocwork KlocworkGatewayPublisher] - Performing Klocwork Server Gateway
    00:01:29.312 [Klocwork KlocworkGatewayPublisher] - Condition Name : *default*
    00:01:29.312 [Klocwork KlocworkGatewayPublisher] - Using query: action=search&project=null&query=grouping:off build%3A<job name>_80+status%3A%2BAnalyze%2C%2BFix
    [Pipeline] }
    [Pipeline] // script
    [Pipeline] }
    [Pipeline] // klocworkWrapper
    Error when executing always post condition:
    hudson.AbortException: Error: failed to connect to the Klocwork web API.
    Cause: null
    	at com.emenda.klocwork.KlocworkGatewayPublisher.perform(KlocworkGatewayPublisher.java:103)
    	at com.emenda.klocwork.KlocworkGatewayPublisher.perform(KlocworkGatewayPublisher.java:66)
    	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:80)
    	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:67)
    	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1$1.call(SynchronousNonBlockingStepExecution.java:50)
    	at hudson.security.ACL.impersonate(ACL.java:290)
    	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1.run(SynchronousNonBlockingStepExecution.java:47)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    	at java.lang.Thread.run(Thread.java:748)


    I find strange that it finds the klocwork buildWrapper seems to setup the configuration as it does for klocwork analysis step, but fails to connect to the Klocwork Web API.

     

    1. Hi Jean-luc,

      Right, to confuse things slightly the KlocworkQualityGateway step in the pipeline is the implementation for KlocworkGatewayPublisher. In the file that exposes the quality gateway to the pipeline: https://github.com/jenkinsci/klocwork-plugin/blob/master/src/main/java/com/emenda/klocwork/pipeline/KlocworkGatewayStep.java you should notice the name "klocworkQualityGateway" as for my config advice on line 78, this configuration calls the KlocworkGatewayPublisher class on line 64.

      So there is no need to configure a pipeline for KlocworkGatewayPublisher as this isn't a real step and by configuring klocworkQualityGateway you will be calling the KlocworkGatewayPublisher with the correct klocwork config settings. So if you are trying to set a quality gateway fail/pass the build based on a threshold then you've achieved that with klocworkQualityGateway.

      By any chance were you actually trying to call the publish step "Klocwork - Publish Klocwork test result report"? If so this step is not supported in pipelines, but were working on replacing it.

      Best Regards,

      Michael

  14. Hi Michael,

    Ok, I understand.
    But something remains not clear for me (bad english understanding ?).
    Do you mean that it is currently not possible to publish klocwork test results on a job page ? Even using an all purpose script as the one I tried ?
    In fact, I though it was possible just as for Robot Framework plugin. It does not offer a pipeline interface to do that natively, but it can be done with a script step as below :

               script{
                    step([
                        $class: 'RobotPublisher', 
                        disableArchiveOutput: false, 
                        logFileName: 'log.html', 
                        otherFiles: '', 
                        outputFileName: 'output.xml', 
                        outputPath: "${WORKSPACE}/testing/robotframework", 
                        passThreshold: 100, 
                        reportFileName: 'report.html', 
                        unstableThreshold: 0
                    ])
                }

    I was looking for coding something equivalent for Klocwork results.

  15. Hi Jean-luc,

    It is possible to publish klocwork test results to the job page (graphs etc) using an old step "Klocwork - Publish Klocwork test result report" in a normal GUI type job. This step doesn't have a native pipeline interface and a few people have tried, but haven't had much success with workarounds to use this in a pipeline. From our point of view we haven't tried too much as the configuration and code for this step is fairly bad (requiring the server details all over again etc), so the plan is to replace it as we have done the other steps.

    You are more than welcome to have a go however the class in question is: KloPublisher found at https://github.com/jenkinsci/klocwork-plugin/blob/master/src/main/java/com/thalesgroup/hudson/plugins/klocwork/KloPublisher.java 

    But this class doesnt have any configuration of its own and instead uses a separate class for configuration called KloConfig which can be found at: https://github.com/jenkinsci/klocwork-plugin/blob/master/src/main/java/com/thalesgroup/hudson/plugins/klocwork/config/KloConfig.java

    Best regards,

    Michael

  16. Michael,

    Thanks a lot for your help.
    I think I will either wait a little or perhaps trigger a Freestyle job. I am not skilled enough in java to try to adapt something that could use the KloPublisher.

    By the way, if I correctly understand, the current Klocwork plugin will be replace with a totally new one which natively takes into account pipelines. Am I true ?
    If yes, have you an (even approximate) idea of the delivery date ?

    Thanks again, and have a nice week-end !

    1. Hi Jean-Luc,

      Some of the original features i.e. the trend graphs (with improvements)& Klocwork review link with pipeline support will be out very shortly. We already have the code written for this and I'm currently just testing this. I would expect for a release next week.

      Best regards,

      Michael

      Emenda Support

  17. Hello everyone,

    I recently updated my Klocwork plugin to the lastest version and I noticed something : the Klocwork Resultat Details disappeared ( there is a screenshot from Greg Moncreaf dated from the 15 November 2011 that shows what i'm talking about).

    So I would like to know if it's an error or if it's normal.

    Thank you very much and have a nice day !

    1. Hi,

      This is currently the intended behaviour. The results page generated by the plug-in (as shown by the mentioned screen shot in 2011) should currently only show the 'metrics' i.e total count and count per severity and the specific issue details list has been removed. The reason for this decision was that the issues had to be stored in the build.xml for the job run and then loaded into memory when viewing the results page. We found many users with large numbers of issues were seeing the file size limit for the build.xml being exceeded and thus the build disappearing from the job and also large memory impact on the Jenkins server when loading the results into the web page.

      We do intend to bring back this feature, but are still discussing the best implementation of it so it currently isn't timetabled.

      Best Regards,

      Michael

      Emenda Support

  18. Hi Michael,

    Thank you very much for your answer.

    I don't know if I can post it here, but I have another one question/problem about my recent update.

    So, when I am on the main page of my Jenkins' build, the link for the Klocwork Result doesn't work. I know it's not really clear so I put a screen shot to illustrate what I said : 

     

     

     

    I don't understand this bug because I have a kloResult and if put " http://my_server_jenkins/job/name_job/number_job/kloResult " i can see it.

     

    Thank you 

    Biyagui

     

     

  19. Hi Biyagui,

    What version of Jenkins are you using?

    Best Regards,

    Michael

    1. Hi Michael,

      Sorry I was facing issues that prevented me to answer earlier.

      Currently, I'm using the 2.3.7 version of the Klocwork plugin.

      Thanks you very much.

      Best regards,

      Biyagui