Running PVS-Studio in TeamCity

Automating the analyzer run

In order to automate the analysis process in CI (Continuous Integration), you need to run the analyzer as a console application.

You need to create a Build Step in TeamCity with the following parameters:

Runner type: Command Line;

  • Step Name: <name>;
  • Run: Custom script;
  • Custom script: <script>.

In the script, write the analysis command (and the command for converting the report in the needed format).

Examples of commands to run the analyzer, handle the analysis results and integrate the analyzer into build systems are given on the following pages of documentation:

Viewing analysis results

The first way

In TeamCity you can attach analyzer reports in the HTML format to builds, having specified them in the artifacts.

Here are some ways to generate an HTML report with navigation along the code:

Windows: C, C++, C#

PlogConverter.exe ... --renderTypes FullHtml ...

Linux/macOS: C, C++

plog-converter ... --renderTypes fullhtml ...

Windows/Linux/macOS: Java

In the plugins settings for Maven and Gradle in the outputType field set the fullhtml value.

In the menu Edit Configuration Settings > General Settings > Artifact paths specify the directory with the resulting HTML-report.

After successful build, the analyzer report will appear on the new tab in this build information:

When clicking analyzer warnings, additional browser tabs will be opening:

In other CIs, configuration of analyzer runs and working with reports are performed in the same way.

The second way

The converter supports standard reports for TeamCity - TeamCity Inspections Type. After generation a report it has to be output in stdout at any step of the build.

Such report can be generated and output in stdout in the following ways:

Windows: C, C++, C#

PlogConverter.exe ... –-renderTypes=TeamCity -o TCLogsDir ...
Type TCLogsDir\MyProject.plog_TeamCity.txt

Linux/macOS: C, C++

plog-converter ... -t teamcity -o report_tc.txt ...
cat report_tc.txt

Windows/Linux/macOS: Java

Support will be available soon.

After successful build execution the analyser report will appear in a new tab with the information on this build:

In order to navigate along the code you can click the line number on the left of the diagnostic rule. The transition will occur if there is an absolute path to the source file, the open project in an IDE (Eclipse, Visual Studio, IntelliJ IDEA), and the installed TeamCity plugin.

Additional links


Bugs Found

Checked Projects
381
Collected Errors
13 764