Pour obtenir une clé
d'essai remplissez le formulaire ci-dessous
Demandez des tariffs
Nouvelle licence
Renouvellement de licence
--Sélectionnez la devise--
USD
EUR
RUB
* En cliquant sur ce bouton, vous acceptez notre politique de confidentialité

Free PVS-Studio license for Microsoft MVP specialists
To get the licence for your open-source project, please fill out this form
** En cliquant sur ce bouton, vous acceptez notre politique de confidentialité.

I am interested to try it on the platforms:
** En cliquant sur ce bouton, vous acceptez notre politique de confidentialité.

Votre message a été envoyé.

Nous vous répondrons à


Si vous n'avez toujours pas reçu de réponse, vérifiez votre dossier
Spam/Junk et cliquez sur le bouton "Not Spam".
De cette façon, vous ne manquerez la réponse de notre équipe.

>
>
Running PVS-Studio in Jenkins
Analyzer diagnostics
General Analysis (C++)
General Analysis (C#)
General Analysis (Java)
Diagnosis of micro-optimizations (C++)
Diagnosis of 64-bit errors (Viva64, C++)
Customer specific requests (C++)
MISRA errors
AUTOSAR errors
OWASP errors (C#)
Problems related to code analyzer
Additional information
Contents

Running PVS-Studio in Jenkins

26 Sep 2019

Automating the analyzer run

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

In Jenkins you can create one of the following build steps:

  • Execute Windows batch command
  • Windows PowerShell
  • Execute shell

and write the analysis command (and the command to convert the report in the needed format).

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

Plugin to visualize analysis results

Download the PVS-Studio Plugin on the download page in the section about Jenkins. The pvs-studio.hpi file will be saved on the disk. Jenkins plugins are distributed in such packages for manual installation.

You can install the plugin via UI by going to the menu Manage Jenkins > Manage Plugin > Advanced > Upload Plugin > Choose File, or via Jenkins CLI:

java -jar jenkins-cli.jar -s http://localhost:8080/ install-plugin SOURCE ...

PVS-Studio Plugin enables publishing static analysis results. To do this, it uses the analyzer report as an .html file, formed in the following ways:

Windows: C, C++, C#

PlogConverter.exe ... --renderTypes Html ...

Linux/macOS: C, C++

plog-converter ... --renderTypes html ...

Windows/Linux/macOS: Java

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

To publish the analysis results in the project settings you have to add the post-build step (section Post-build Actions) Publish PVS-Studio analysis result. Mandatory field - Path to PVS-Studio analysis report, which sets the path to the .html file, the contents of which will be displayed on the build page. Relative (related to project's workspace) paths are supported. Jenkins' environment variables are also supported.

If you need to display combined results from several analyzer reports, you can combine them using the above converting utilities. Additional filtration of analysis results is available in a similar way.

To use the plugin from pipeline scripts, add the following:

step([$class: 'PVSStudioPublisher', targetHtmlPath: 'report.html'])

where report.html is a path to an .html report file.

After successful publishing of PVS-Studio analysis results, they will be displayed on build pages. The results of the analysis are saved for each build that allows you to view the analyzer report corresponding to a specific build.

If the resulting analyzer report is large, its preview will be displayed on the build page. The full report will be available for viewing by clicking the links View full report over / under the report preview, or Full PVS-Studio analysis report in the menu on the left.

Build page look, displaying the results of PVS-Studio analysis:

Jenkins/image1.png

Warnings Next Generation plugin

Warnings NG plugin supports PVS-Studio analyzer reports, starting from the plugin version 6.0.0. This plugin is designed to visualize the results of various analyzers.

You can install the plugin from the standard Jenkins repository in the menu Manage Jenkins > Manage Plugins > Available > Warnings Next Generation Plugin:

Jenkins/image3.png

To publish the analysis results, in project settings, you have to add the post-build step (Post-build Actions section) Record compiler warnings and static analysis results.. Next, you need to open the list Tool and choose PVS-Studio. In the Report File Pattern field you can specify the mask or the path to the analyzer report. Reports with extensions .plog and .xml.are supported.

The Report Encoding field specifies the encoding in which the report file will be read. If the field is empty, the encoding of the operation system in which Jenkins is run, will be used. Fields Custom ID and Custom Name override the identifier and the name of the chosen utility in the interface.

To publish analysis results through pipeline scripts, add the following:

recordIssues enabledForFailure: true,sourceCodeEncoding:'UTF-8',
 tool: PVSStudio(pattern: 'report.plog')

where report.plog is the analyzer report.

Here are some ways to generate a report in the needed format:

Windows: C, C++, C#

Reports with .plog extension are standard for Windows.

Linux/macOS: C, C++

plog-converter ... --renderTypes xml ...

Windows/Linux/macOS: Java

In the settings for plugin for Maven and Gradle in the outputType field set the value xml.

After building the project a new element will appear in the PVS-Studio Warnings menu on the left. Clicking on it opens a page that visualizes data of the report created by the PVS-Studio analyzer:

Jenkins/image4.png

Also, when you click on the value in the File column, the browser will open a source file on the line where the error was found. If the file doesn't open, it means that the report was generated outside the build directory or the files involved in the report have been moved or deleted.

Jenkins/image6.png

In other CIs, configuration of the analyzer run and handling reports are performed in the same way.

Additional links

Unicorn with delicious cookie
Nous utilisons des cookies pour améliorer votre expérience de navigation. En savoir plus
Accepter