rv2rx
rv2rx

Reputation: 31

How to make cpplint work with Jenkins warnings plugin

I added an 'Execute shell' build step in Jenkins to run the cpplint.py

python /var/lib/jenkins/scripts/cpplint.py --counting=detailed `find path -name *.cpp

I also added 'Scan for compiler warnings' and added CppLint.

However it always gets 0 warnings even though it displayed in the Console output some warnings such as

filename.cpp:18:  Missing space after ,  [whitespace/comma] [3]

Upvotes: 3

Views: 5375

Answers (2)

Ed of the Mountain
Ed of the Mountain

Reputation: 5459

I use the Cppcheck Plugin and cpplint_to_cppcheckxml.py to convert cpplint.py output to the XML format expected by Cppcheck Plugin. This works really well. I can click on the offending issue in Cppcheck Results displayed on the Jenkins job page and it will display the source code with offending line highlighted. Very cool.

You must provide cpplint an absolute path to your source code directory in order for the hyperlink generation to work on Cppcheck Results page. The only con I see is your Cppcheck and cpplint results are combined and not separated.

If using Linux bash scripts, here is how I turn a relative path into absolute in order for the cpplint to generate absolute paths in it's output:

# Build cpplint reports and transform to cppcheck compatible XML format
# Convert relative path to absolute path so that Jenkins job can easily display the source code errors
srcPathAbsolute=${PWD}/../dicegame/src/main
srcPathAbsolute=$(readlink -f ${srcPathAbsolute})
cpplint.py --counting=detailed ${srcPathAbsolute}/*.cpp  2>&1| cpplint_to_cppcheckxml.py &> cpplint-cppcheck-result.xml 

In my Jenkins job configuration to locate both ccplint-cppcheck-result.xml files and my normal cppcheck-result.xml.

Publish cppcheck results
Cppcheck report XMLs  **/*cppcheck-result.xml

Thanks to original developer of cpplint_to_cppcheckxml.py. This script serves as an example on how to connect output of other tools into existing Jenkins plugins. Very nice!

Upvotes: 3

jsiverskog
jsiverskog

Reputation: 63

If you run cpplint.py with --output=vs7 it will produce the format expected by the Jenkins warnings plugin.

Upvotes: 6

Related Questions