Latest features:

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!

Changelog

Version 2.4.7

Bug Fix: Resolved issue introduced in 2.4.6 where global server/install settings were not being saved. No impact or change to configuration should be needed.

Bug Fix: Resolved issue where the trend graph and Klocwork link introduced in 2.4.3 were not showing in pipeline jobs. No impact or change to configuration should be needed.

Bug Fix: Resolved issue when generating a pipeline snippet on step 'klocworkIntegrationStep2'. No impact or change to configuration should be needed.

Version 2.4.6

Feature: Added the ability to use with jcasc plugin. No impact or change to configuration should be needed.

Version 2.4.5

Bug Fix: Resolved issue in which when reading the ltoken file the resource was not closed. No impact or change to configuration should be needed.

Version 2.4.4

Bug Fix: Post-build step "Klocwork Gateway". The query string sent to the server was being incorrectly formatted due to errors in the code. No impact or change to configuration should be needed.

Version 2.4.3

New feature: Added trend graph and link to Klocwork review to the main product page. Configuration can be found in the integration step for loading. This does impact pipeline configuration

Important note: This version requires an update to the pipeline scripts running integration builds to continue to run. Please find examples below:

Version 2.4.2

Bug fix: Dashboard feature caused a could "not serialize" bug in some environments. Implemented Serializable for KlocworkIssue. No impact to existing configuration expected.

Version 2.4.1

Bug fix: Dashboard feature caused a could "not serialize" bug in some environments. Implemented Serializable for KlocworkSeverities and KlocworkStatuses. No impact to existing configuration expected.

Version 2.4.0

Bug fix: Dashboard feature caused a could "not serialize" bug in some environments. Implemented Serializable for KlocworkXMLReportParser and KlocworkXMLReportParserIssueList. No impact to existing configuration expected.

Version 2.3.9

New feature: Added parameter to Klocwork CI gateway to "report results". This creates a link on the build/project page to "Klocwork Dashboard" which allows issues to be seen. No impact to existing configuration expected.

New feature: Changed step Klocwork CI gateway to allow multiple quality gates similar to the integration build. No impact to existing configuration expected.

New feature: Changed step Klocwork CI gateway to include filtering on severities and statuses. No impact to existing configuration expected.

Version 2.3.8

New feature: Added parameter to Klocwork CI gateway to allow the build to fail as unstable rather than failure. No impact to existing configuration expected.

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 1.15

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

Version 1.8.1

Version 1.8

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.

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

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.

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

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 :

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.

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 :

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.

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 ?

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.

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).

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.