-
Improvement
-
Resolution: Fixed
-
Minor
-
Powered by SuggestiMate
Add support for Jenkins Pipeline with Cppcheck Plugin
https://github.com/jenkinsci/pipeline-plugin/blob/master/COMPATIBILITY.md
- is blocked by
-
JENKINS-41704 Clicking On `Cppcheck Results` From A Multi-Branch Pipeline Build Results In javax.servlet.ServletException: org.apache.commons.jelly.JellyTagException
-
- Resolved
-
-
JENKINS-42613 Cppcheck publisher has no access to source files (experimental version for pipeline)
-
- Closed
-
[JENKINS-35096] Add support for Jenkins Pipeline to the cppcheck-plugin
Hi,
Do you know by chance the status of this issue. Can one now invoque Cppcheck in a pipeline and upload the xml output file?
thanks.
I did some experiments here: https://github.com/raynigon/CppCheckV2-Plugin
i dont know if its possible to merge this with the original CppCheck Plugin in the future.
nabilg Eventually this could solve your Problem, but be carefull its currently under Development
raynig I would love to try your experimental plugin. Any known issues?
Pushed branch https://github.com/jenkinsci/cppcheck-plugin/tree/jenkins-35096_cppcheck_plugin_pipeline_support . Anybody interested in that issue, feel free to comment on the changes.
Thank you for making the update. The Pipeline Syntax code snippets now includes a 'step: General Build Step' > 'Publish Cppcheck results' step.
However I am having some difficulty in correctly configuring the plugin. The 'Generate Pipeline Script' button produces the following when trying to make code for a 'foo.xml' report:
step <object of type org.jenkinsci.plugins.cppcheck.CppcheckPublisher>
That does not work at all in a Pipeline Jenkinsfile. Based on another pipeline step I tried `step([$class: 'CppcheckPublisher'])` and `step([$class: 'CppcheckPublisher', cppcheckReportPattern: 'cppcheck.xml'])` but those both try to check for a '**/cppcheck-result.xml' file.
Is there any documentation for the intended syntax?
Could the Pipeline Syntax Snippet Generator output be fixed?
Renaming my report file to match the expected default got me a little bit further. The build completed. However I ended up with an issue when I clicked the `Cppcheck Results` link added to the side of the build. See https://issues.jenkins-ci.org/browse/JENKINS-41704 for further details.
A documentation on that will be provided (just don't know yet where to put it correctly...): Until that here is my test-command for the pipeline:
stage "cppcheck"
step([$class: 'CppcheckPublisher',
pattern: "testcppcheck*.xml",
ignoreBlankFiles: false, threshold: "19",
allowNoReport: false,
newThreshold: "", failureThreshold: "",
newFailureThreshold: "", healthy: "", unHealthy: "",
severityError: true,
severityWarning: true,
severityStyle: true,
severityPerformance: true,
severityInformation: true,
severityNoCategory: true,
severityPortability: true,
xSize: 1000, ySize: 200,
numBuildsInGraph: 0,
displayAllErrors: true,
displayErrorSeverity: true,
displayWarningSeverity: true,
displayStyleSeverity: true,
displayPerformanceSeverity: true,
displayInformationSeverity: true,
displayNoCategorySeverity: true,
displayPortabilitySeverity: true])
Hi Marco Steffan,
I'd like to give your plugin modifications a try as well. I tried to create the plugin by cloning the repository and building it with maven, but then I ran in some (noob?) problems.
- git clone git@github.com:jenkinsci/cppcheck-plugin.git
- cd cppcheck-plugin/
- git checkout jenkins-35096_cppcheck_plugin_pipeline_support
- mvn packge
Then I got the following error below. Did I do something wrong?
[INFO] Scanning for projects... [ERROR] [ERROR] Some problems were encountered while processing the POMs: [FATAL] Non-resolvable parent POM for org.jenkins-ci.plugins:cppcheck:1.22-SNAPSHOT: Failure to find org.jenkins-ci.plugins:plugin:pom:2.16 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 4, column 13 @ [ERROR] The build could not read 1 project -> [Help 1] [ERROR] [ERROR] The project org.jenkins-ci.plugins:cppcheck:1.22-SNAPSHOT (/home/marten/Projects/cppcheck-plugin/pom.xml) has 1 error [ERROR] Non-resolvable parent POM for org.jenkins-ci.plugins:cppcheck:1.22-SNAPSHOT: Failure to find org.jenkins-ci.plugins:plugin:pom:2.16 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 4, column 13 -> [Help 2] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException [ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
Thank you for the example test command. That should be very helpful.
martenlootsma that looks more like an issue with your maven configuration. See the steps here to setup your maven config: https://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorial#Plugintutorial-SettingUpEnvironment Ensure that you have maven3 (mvn -V) is installed.
Hi marcosteffan, the plugin update is already useful Thank you. One thing which does not work for me yet is the code view. When I click on the line number of an issue I get the raw html in stead of a nice formatted page:
Cppcheck Results
Content of file TTN_Gateway/firmware/src/custom_http_app.c
<!-- ======================================================== --> <!-- = Java Sourcecode to HTML automatically converted code = --> <!-- = Java2Html Converter 5.0 [2006-02-26] by Markus Gebhard markus@jave.de = --> <!-- = Further information: http://www.java2html.de = --> <div align="left" class="java"> <table border="0" cellpadding="3" cellspacing="0" bgcolor="#ffffff"> <tr> <!-- start source code --> <td nowrap="nowrap" valign="top" align="left"> <code> <a name="1"><font color="#808080">0001</font> </a><font color="#3f5fbf">/*******************************************************************************</font><br /> <a name="2"><font
Can you reproduce that issue?
Marten
martenlootsma I could reproduce that report and have fixed it meanwhile - just pull the branch.
Thank you for your fast update marcosteffan. Unfortunately building the plugin stops at the tests, see stack trace below. Building without the test results in a usable HPI with indeed the reported bug fixed.
Tests run: 31, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 13.281 sec <<< FAILURE! - in InjectedTest com/thalesgroup/hudson/plugins/cppcheck/CppcheckSource/index.jelly(org.jvnet.hudson.test.JellyTestSuiteBuilder$JellyCheck) Time elapsed: 0.026 sec <<< FAILURE! java.lang.AssertionError: <?jelly escape-by-default='true'?> is missing in file:/home/marten/Projects/cppcheck-plugin/target/classes/com/thalesgroup/hudson/plugins/cppcheck/CppcheckSource/index.jelly at org.jvnet.hudson.test.JellyTestSuiteBuilder$JellyCheck.runTest(JellyTestSuiteBuilder.java:108) at junit.framework.TestCase.runBare(TestCase.java:134) at junit.framework.TestResult$1.protect(TestResult.java:110) at junit.framework.TestResult.runProtected(TestResult.java:128) at junit.framework.TestResult.run(TestResult.java:113) at junit.framework.TestCase.run(TestCase.java:124) at junit.framework.TestSuite.runTest(TestSuite.java:243) at junit.framework.TestSuite.run(TestSuite.java:238) at org.jvnet.hudson.test.junit.GroupedTest.runGroupedTests(GroupedTest.java:67) at org.jvnet.hudson.test.JellyTestSuiteBuilder$JellyTestSuite.doTests(JellyTestSuiteBuilder.java:152) at org.jvnet.hudson.test.JellyTestSuiteBuilder$JellyTestSuite.access$100(JellyTestSuiteBuilder.java:138) at org.jvnet.hudson.test.JellyTestSuiteBuilder$JellyTestSuite$2.call(JellyTestSuiteBuilder.java:160) at org.jvnet.hudson.test.HudsonTestCase$WebClient$5.run(HudsonTestCase.java:1610) at org.jvnet.hudson.test.ClosureExecuterAction.doIndex(ClosureExecuterAction.java:53) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:335) at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:175) at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:108) at org.kohsuke.stapler.IndexDispatcher.dispatch(IndexDispatcher.java:26) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876) at org.kohsuke.stapler.MetaClass$10.dispatch(MetaClass.java:362) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:649) at org.kohsuke.stapler.Stapler.service(Stapler.java:238) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:135) at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:126) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:86) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84) at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76) at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:553) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.eclipse.jetty.server.Server.handle(Server.java:499) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) 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:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Results : Failed tests: JellyTestSuiteBuilder$JellyCheck.runTest:108 <?jelly escape-by-default='true'?> is missing in file:/home/marten/Projects/cppcheck-plugin/target/classes/com/thalesgroup/hudson/plugins/cppcheck/CppcheckSource/index.jelly Tests run: 58, Failures: 1, Errors: 0, Skipped: 0
Hi martenlootsma,
the tests should be fixed (again). Sorry for the lots of updates..
https://github.com/jenkinsci/cppcheck-plugin/compare/jenkins-35096_cppcheck_plugin_pipeline_support
Are there any plans to get this merged and published soon?
Hi marcosteffan, I'm getting "step <object of type org.jenkinsci.plugins.cppcheck.CppcheckPublisher>" when I try to use the pipeline syntax generator.
("Step: General build step" and then "Publish Cppcheck results")
Known issue?
Branch: jenkins-35096_cppcheck_plugin_pipeline_support, comimit: 9191d1515d2478820be325c0a5cad4b252f5bbb5
This functionality is highly required here! What are the integration plans?
Cheers!
marcosteffan I tried building the latest changes with Java8 and encountered some issues with the JavaDocs,
See https://github.com/jenkinsci/cppcheck-plugin/pull/35 for an update.
hey rvdk I think i have narrowed down your syntax generator issue.
try building from
https://github.com/James-Dengel/cppcheck-plugin/tree/pipline_changes
It's based off of Marco's awesome work, but I am not much of a java expert.
Hello Marco,
I created a pull-request for this issue, with a complete operational pipeline implementation for this plugin.
Internally we are already using it successfully, See https://github.com/jenkinsci/cppcheck-plugin/pull/37
I've merged AltranManatree:jenkins-35096_Altran_cppcheck_plugin_pipeline_support with master branch, uploaded the plugin and it works with the pipeline.
One issue left is that main Cppcheck link is not accessible. An error occurs:
org.apache.commons.jelly.JellyTagException: jar:file:/mnt/work/jenkins-home/plugins/cppcheck/WEB-INF/lib/cppcheck.jar!/org/jenkinsci/plugins/cppcheck/CppcheckProjectAction/nodata.jelly:4:64: <st:include> No page found 'sidepanel.jelly' for class org.jenkinsci.plugins.cppcheck.CppcheckProjectAction
Also pipeline syntax snippet generator allows to choose step: general build step - publish cppcheck results but result always looks bad:
step <object of type org.jenkinsci.plugins.cppcheck.CppcheckPublisher>
I seem to have a working version.
Still got a few wrinkles when using the step generator; the defaults are not displayed.
Why is this issue resolved and listed as Release 1.22? Still can't use it?
It is also behaving faulty on my Jenkins instace. Update gave me several hours of troubleshooting/rebuilding cppcheck to 1.21, reuploading and so on. I have Jenkins ver. 2.73.3.
Error:
org.apache.commons.jelly.JellyTagException: jar:file:(...)/jenkins-home/plugins/cppcheck/WEB-INF/lib/classes.jar!/org/jenkinsci/plugins/cppcheck/CppcheckResult/index.jelly:3:62: <st:include> No page found 'sidepanel.jelly' for class org.jenkinsci.plugins.cppcheck.CppcheckResult
Am on version 1.22
Using the example provided above but it keeps trying to read a file called `**/cppcheck-result.xml`
Any way to solve this? Or will this be fixed in a future version?
I have the same problem as daan_philips ...
[Cppcheck] java.lang.IllegalArgumentException: No cppcheck test report file(s) were found with the pattern '**/cppcheck-result.xml'
although I configured a different path in the pipeline syntax:
step([$class: 'CppcheckPublisher', pattern: 'Testing/cppcheck-report.xml', ignoreBlankFiles: false, threshold: "0", ........
Hi marcosteffan , djviking ,
When I add stage
stage "cppcheck"
step([$class: 'CppcheckPublisher', to my jenkinfile
it raises a warning and it seems to be the failure
Maybe CppcheckPublisher doesn't have var member like displayInformationSeverity, xSize, ySize
Could you help me to solve this issue?
Thanks
I think what's needed is to implement the `SimpleBuildStep` class interface. similar to what the xunit plugin does: https://github.com/jenkinsci/xunit-plugin/blob/master/src/main/java/org/jenkinsci/plugins/xunit/XUnitPublisher.java#L63
cppcheck does not implement this:
https://github.com/jenkinsci/cppcheck-plugin/blob/master/src/main/java/org/jenkinsci/plugins/cppcheck/CppcheckPublisher.java#L32
See also: https://github.com/jenkinsci/cobertura-plugin/issues/50