Send Email Notifications with Polyspace Bug Finder 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:

  1. 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.

  2. 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 exports 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 in the Polyspace Bug Finder™ Access™ interface. 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. 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 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 Bug Finder Access interface from the command line. For instance, navigate to polyspaceserverroot\polyspace\bin and enter:

    polyspace-access login -list-project

    Here. polyspaceserverroot is the Polyspace Bug Finder Server™ installation folder, for instance, C:\Program Files\Polyspace Server\R2019a.The variable login refers to the following combination of options. You provide these options with every use of the polyspace-access command.

    -host hostName -port portNumber -login username -encrypted-password pwd

    Here, hostName is the name of the Polyspace Bug Finder Access web server. For a locally hosted server, use localhost. portNumber is the optional port number of the server. If you omit the port number, 9443 is used. username and pwd refer to the login and an encrypted version of your password. To create an encrypted password, enter:

    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. To see only new defects compared to the previous analysis of the same project, use the option -new-findings.

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.

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

See Also