Our website uses cookies to enhance your browsing experience.
Accept
to the top
close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
** By clicking this button you agree to our Privacy Policy statement
close form
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
* By clicking this button you agree to our Privacy Policy statement

close form
Free PVS‑Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

close form
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

close form
I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

>
>
Running PVS-Studio in Jenkins
menu mobile close menu
Analyzer diagnostics
General Analysis (C++)
General Analysis (C#)
General Analysis (Java)
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
toggle menu Contents

Running PVS-Studio in Jenkins

Sep 26 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.

Note. In Jenkins, to view warnings from the uploaded analyzer report in source code files (the links in the File column), the following condition must be met: when starting the Record compiler warnings and static analysis results step (the Post-build Actions section), the project files, whose paths are specified in the analyzer report (*.plog file), should be located in the Jenkins job workspace. The source code files to which the analyzer issued warnings are cached for each build of the Jenkins job. So, after performing the Record compiler warnings and static analysis results step (the Post-build Actions section), you can clear the Jenkins job workspace without losing the ability to view warnings in source code files using Jenkins. If files do not open, then the report was created outside the Jenkins job workspace, or the cached source code files (that were used to create the report) in the Jenkins job build directory 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