If you run a Polyspace® analysis as part of continuous integration, each new code submission produces new results. You not only see new results in components that were modified but also in components that depended on the modified components. You can set up e-mail alerts so that component owners get notified when new Polyspace results appear in their components.
To create e-mail notifications:
Export new analysis results to a tab-delimited text file
(.tsv
format).
Apply filters to export specific types of results, for instance, defects with high impact. If required, you can also apply additional filters to the exported files using search and replace utilities. See Export Results for E-mail Attachments.
Send an email with the results file in attachment. For each result, the attachment contains links to open the result in the Polyspace Code Prover™ Access™ web interface.
For instance, if you use an e-mail plugin in Jenkins, you can create a post-build step to send an e-mail after the analysis is complete.
If you use the Polyspace plugin in Jenkins, you can use Polyspace helper utilities for the entire e-mail notification process. See Sample Scripts for Polyspace Analysis with Jenkins
Alternatively, results can be directly assigned to owners based on their file paths. You can set up email notifications that exports a separate results file per owner and sends an email to each owner with the corresponding results file in attachment.
To run this tutorial:
You must have uploaded some result in the Polyspace
Code Prover
Access interface. If you complete the tutorial Run Polyspace Code Prover on Server and Upload Results to Web Interface, you should see a folder testProject
on the
PROJECT EXPLORER pane. The folder contains one
project myFirstProject
.
To see the results in the project, with
myFirstProject
selected, click the
Review button. You see a list of run-time
checks. The Type column shows the color of the
checks. In this tutorial, only red checks will be exported for e-mail
attachments.
You must be able to interact with the Polyspace
Code Prover
Access interface from the command line. For instance, navigate to
and enter:polyspaceserverroot
\polyspace\bin
polyspace-access login -list-project |
Here.
is
the Polyspace
Code Prover
Server™ installation folder, for instance, polyspaceserverroot
C:\Program
Files\Polyspace Server\R2020b
.The variable
refers to
the following combination of options. You provide these options with
every use of the login
polyspace-access
command.
-host hostName -port portNumber -login username -encrypted-password pwd |
Here,
is the
name of the Polyspace
Code Prover
Access web server. For a locally hosted server, use
hostName
localhost
.
is the
optional port number of the server. If you omit the port number,
portNumber
9443
is used.
and
username
refer to the
login and an encrypted version of your password. To create an encrypted
password, enter:pwd
polyspace-access -encrypt-password |
Copy the encrypted password and provide this password
with later uses of the polyspace-access
command.
You can export all results in a project or only certain types of results.
Open a command window. Navigate to the folder where you want to export the results.
To export all results, enter the following:
polyspace-access login -export testProject/myFirstProject -output .\result.txt |
To export only red checks, enter the following:
polyspace-access login -export testProject/myFirstProject -rte Red -output .\result_red_checks.txt |
Open each text file in a spreadsheet viewing utility such as Microsoft®
Excel®. In the first file, you see all results but in the second file, you
only see the red run-time checks. Instead of -rte Red
, you can
apply other filters.
To see only new results compared to the previous analysis of the same
project, use the option -new-findings
.
To apply a more fine-grained set of filters, you can use software
quality objectives (SQOs). The software quality objectives are specified
through a progressively stricter set of SQO levels, numbered from 1 to
6. You can customize the requirements of each level in the Polyspace Access web interface, and then use the option
-open-findings-for-sqo
with the level number to
export only those results that must be reviewed to meet the
requirements. See also Software Quality Objectives (Polyspace Code Prover Access).
To see all filtering options, enter:
polyspace-access -h -export |
You can configure your e-mail utility to send these exported files in attachment.
If required, you can also apply additional filters to the exported files using
search and replace utilities. For instance, use search and replace utilities on the
results file to include results only from specific files and functions. In
Linux®, you can use grep
and sed
to
retain only results in specific files.
You can assign owners to results in specific files or folders. You can then export one result file per owner and send an email to each owner with the corresponding file in attachment.
You can assign owners in the Polyspace Code Prover Access web interface or at the command line.
In this tutorial, assign all results in the file example.c
to
jsmith
and all results in the file
single_file_analysis.c
to
jboyd
.
polyspace-access login -set-unassigned-findings testProject/myFirstProject -owner jsmith -source-contains example.c polyspace-access login -set-unassigned-findings testProject/myFirstProject -owner jboyd -source-contains single_file_analysis.c |
After assignment, export one results file per owner.
polyspace-access login -export testProject/myFirstProject -output .\results.txt -output-per-owner |
These files contain the exported results:
results.txt
contains all results.
results_jsmith.txt
and
results_jboyd.txt
contains results assigned to
jsmith
and jboyd
respectively.
results.txt.owners.list
contains the list of
owners, in this
case:
jsmith jboyd
Before assigning owners to results, use the option -dryrun
to
perform a dry run of the assignments. Without performing the assignment, the option
shows the files with results that are assigned and the owner that the results are
assigned to.