Redirect CppCheck output using command line build step fails


I would like to run cppcheck on our code as part of our build. However, I cannot make it save the output to a file using the command line build step.

From a regular (windows) command prompt the following works fine:

"C:\Program Files\Cppcheck\CppCheck.exe" --enable=all  --xml-version=2 "<full_path_with_spaces_to_source>" 2> cppcheck_result.xml

When runing the same from within TeamCity no output file is created! The check is performed and the normal output is seen in the build log, but somehow the 2> is lost. I am using TeamCity version 7.1.1.

I have searched everywhere I could think of,and the closest I could find was this:

But this did not work for me, so any help would be greatly appreciated.

Alternatively, I you know of a better way to run cppcheck and get the results, please let me know.


Comment actions Permalink

Hi Kim

Try to change the redirection syntax from 2> to just >
It should allow to write all tool's outbut to the file, not error messages.

Comment actions Permalink

Hi Michael,

Thank you for your reply. But unfortunately this does not work either. No file is created!

CppCheck will run with exit code 0. And I can see the output in the build log, but cannot save it into a file - which I want to keep as an artifact.

Best regards,


Please sign in to leave a comment.