This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Send E-mail Notifications with Polyspace Code Prover 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).

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

Prerequisites

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 polyspaceserverroot\polyspace\bin and enter:

    polyspace-access login -list-project

    Here. polyspaceserverroot is the Polyspace Code Prover 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 Code Prover 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 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 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 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.

See Also