Menu

Suggested feature - TeamCity format output

2015-07-31
2015-08-23
  • Dina Goldshtein

    Dina Goldshtein - 2015-07-31

    I wanted to integrate cppcheck into my TeamCity build. Specifically, I want the results to be reported as build errors. I almost got it using a custom output template, only some characters (such as an apostrophe) need to be escaped. This prevents messages containing variable names to be understood by TeamCity. I thought it would be a great feature to have a built-in output template "tc" which supports this by outputting the correct format and escaping the required characters.
    Ideally, missing system include headers would be reported as warnings and the rest as errors. I also posted a question about it on StackOverflow: http://stackoverflow.com/questions/31692012/teamcity-and-cppcheck-output-template
    Taking in mind the fact that other tools might need other different characters to escape and the escaping character itself might be different, maybe something more general would also be useful:
    --template "##teamcity[...]" --escapeWith "|" --toEscape "'[]|"

    Thanks!

     
  • Daniel Marjamäki

    I don't know how TeamCity works.. Is it possible to use for example sed? or a script?

     

    Last edit: Daniel Marjamäki 2015-08-02
  • Dina Goldshtein

    Dina Goldshtein - 2015-08-20

    I apologize for the late reply. For some reason I thought I'd get a mail notification about any activity here. I guess I was wrong.
    Anyway, TeamCity simply reads the standard output and standard error produced by the build script. If you follow a certain pattern you can make it treat different message format in certain ways. For example you can output a build error message and then TeamCity will understad that there was an error and will display a nice list to the user specifying which is new and which is old, etc.
    For this feature to work correctly, some of the characters require escaping, as you can see here: https://confluence.jetbrains.com/display/TCD9/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-servMsgsServiceMessages

     
  • Alexander Mai

    Alexander Mai - 2015-08-20

    Did you try the suggestion to use an explicit transformation command?
    Running

    cppcheck src/*.cpp  2>&1 1>/dev/null sed -r "s/('\[|\])/|\1/g" | sed -r ':a;N;$!ba;s/\n/\\n/g'
    

    should do something like that.

     
  • Dina Goldshtein

    Dina Goldshtein - 2015-08-23

    I didn't manage to do it with sed or gawk, plus I'm on Windows. But it did give me an idea to write a script that does this. So I wrote a Python script which recognizes if I'm running under TeamCity environment and redirects the output for further processing if needed.
    So I'm all set. Thanks!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.