While doing some jenkins updates I've now dug into this a little more deeply and I can now see exactly why the files are not being displayed. If I go to one of the summary view panes e.g.( cppcheckResult/source.all) I get an error like:
Can't read file: /var/jenkins_home/jobs/<job-directory>/jobs/<jobname>/workspace-files/ed57db50.tmp
However if I go and look at the jenkins_home on the masterI can see that the path should actually be:
/var/jenkins_home/jobs/<job-directory>/jobs/<jobname>/builds/<build-number>/workspace-files/ed57db50.tmp
So it just looks like the plugin is generating the wrong filesystem path( its missing the builds/<buildnumber> bit) and it has nothing to do with the difference in FS path between the jenkins master and the build slave as I get the same issue even if I make cppcheck produce workspace root relative paths for its errors using:
-rp=$WORKSPACE
In the cppcheck command line arguments.
I have some issues with cppcheck plugin when my job run in a slave node. Apparently, cppcheck store the full path off the source file based on the file system in the slave node, but the plugin runs on master node. Also I wish to use pipeline. I find a very simple work around that works with pipeline and slave node:
1) run the cppcheck
2) use https://github.com/danmar/cppcheck/tree/master/htmlreport to build html results
3) publish html on jenkins with Html Publish Plugin
Example:
cppcheck.exe .\ --force --xml-version=2 -q 2> cppcheck-result.xml
python cppcheck-htmlreport --file=cppcheck-result.xml --title=Embedded --report-dir=.\cppcheckResult --report-dir=.\ --source-encoding="iso8859-1"
The disadvantage for this approach is :
reference: https://dunterov.github.io/cppcheck/