Send Email Notifications with Polyspace Bug Finder Server Results
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.
Creating E-mail Notifications
To create e-mail notifications:
Export new analysis results to a tab-delimited text file (
.tsv
format). For each result, the file contains links to open the result in the Polyspace Access web interface.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 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 export a separate results file per owner and sends an email to each owner with the corresponding results file in attachment. See Assign Owners and Export Assigned Results.
Prerequisites
To run this tutorial:
You must have uploaded some result to the Polyspace Access™ web server. If you complete the tutorial Run Polyspace Bug Finder on Server and Upload Results to Web Interface, you should see a folder
testProject
on the Project Explorer pane of the Polyspace Access web interface. The folder contains one projectmyFirstProject
.To see the results in the project, with
myFirstProject
selected, click the Review button. You see a list of defects. The Information column shows the impact of the defects. In this tutorial, only high-impact defects will be exported for e-mail attachments.You must be able to interact with the Polyspace Access interface from the command line. For instance, navigate to
and enter:polyspaceserverroot
\polyspace\binpolyspace-access login -list-project
Here.
is the Polyspace Bug Finder™ Server™ installation folder, for instance,polyspaceserverroot
C:\Program Files\Polyspace Server\R2024b
.The variable
refers to the following combination of options. You provide these options with every use of thelogin
polyspace-access
command.-host hostName -port portNumber -login username -encrypted-password pwd
Here,
is the name of the Polyspace Access web server. For a locally hosted server, usehostName
localhost
.
is the optional port number of the server. If you omit the port number,portNumber
9443
is used.
andusername
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.
Export Results for E-mail Attachments
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 defects with high impact, enter the following:
polyspace-access login -export testProject/myFirstProject -defects High -output .\result_high_impact.txt
Open each text file in a spreadsheet viewing utility such as Microsoft®
Excel®. In the first file, you see all defects but in the second file, you only see
the defects with high impact. Instead of -defects High
, you can apply
other filters. For instance:
To see only new defects 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 Evaluate Polyspace Bug Finder Results Against Bug Finder Quality Objectives.
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.
Instead of exporting to text files, you can also generate reports in PDF or Word using
predefined report templates. For more information, see polyspace-report-generator
.
Assign Owners and Export Assigned Results
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 Access web interface or at the command line.
In this tutorial, assign all results in the file numerical.c
to
jsmith
and all results in the file dataflow.c
to
jboyd
.
polyspace-access login -set-unassigned-findings testProject/myFirstProject -owner jsmith -source-contains numerical.c polyspace-access login -set-unassigned-findings testProject/myFirstProject -owner jboyd -source-contains dataflow.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
andresults_jboyd.txt
contains results assigned tojsmith
andjboyd
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.
See Also
polyspace-access
(Polyspace Access)