Find the Difference Between Scans and Get a List

Coverity on Polaris

Version
latest
Coverity on Polaris can produce a list of issues that have changed since the last scan, showing those that didn't appear previously or those that no longer appear. This is useful when you want to know what has changed or for determining whether branches are okay to merge or release.
Note: There is a similar topic that explains how to compare scans and produce a count of issues, rather than the full list. For more information, refer to Find the Difference Between Scans and Get a Count.

You can produce a list of issues that appear in one place but not another by comparing between branches, revisions or runs, as long as the ids you provide belong to the same project. It's not possible to compare objects of different types, such as a branch to a run.

Compare Two Runs

Request: Use run ids to show what was in run A and not in run B

 curl -X GET https://{subdomain}.cop.blackduck.com/api/query/v1/issues?project-id[]={project_id}&run-id[]={run_id_A}&compare-run-id[]={run_id_B}&page-limit=10
-H "accept: application/vnd.api+json"
-H 'Authorization: Bearer {JWT}'
To use this example (and following examples):
  • Replace the variables inside curly brackets with your own information.
  • Copy the square brackets exactly as they appear.

This example will return a list of issues that appeared in the first run (run_id_A), but not in the second (run_id_B). The result is equivalent to set A minus set B. In addition to runs, you can compare two branches or two revisions.

Notice also that when comparing two branches the attributes for the compared objects are slightly different: The set identified by compare-run-id is subtracted from the set identified by run-id. The following table illustrates how to use the correct attributes for the request.

Table 1. Attributes and values for comparing branches, revisions, or runs
Type of comparison Original set of issues Minus this set of issues
branch branch-id={branch_id_A} compare-branch-id={branch_id_B}
revision revision-id={revision_id_A} compare-revision-id={revision_id_B}
run run-id[]={run_id_A} compare-run-id[]={run_id_B}

For a complete listing of the differences between two runs, you can make an additional request that reverses the order of the id values; if you're comparing earlier and later runs on the same branch, this will reveal issues that are newly found and also the issues that were not found in the later run.

Compare a Run with One Immediately Before or After

When comparing runs, you can use the values earlier and later in place of the compare-run-id value to compare with the run that happens immediately before or after the run indicated by id. The only parameter that can accept earlier or later as a value is compare-run-id.

Using earlier will return issues that appeared in the run indicated by id but not in the run immediately before it.

Using later will return issues that have disappeared between the run indicated by id and the one after it.

Note: When using later to indicate the latest scan, make sure that results of the scan are ready. Otherwise, the result will be an error.

Request: Compare a run with a known id to whatever run came immediately before it

 curl -X GET https://{subdomain}.cop.blackduck.com/api/query/v1/issues/?run-id[]={run_id}&compare-run-id[]=earlier
-H "accept: application/vnd.api+json"
-H 'Authorization: Bearer {JWT}'
            

Compare Multiple Runs

You can provide more than one run id or more than one comparison id. When you provide multiple ids to an attribute, their issues are combined into a single set. This approach is useful when you want to combine all the runs from a period of time, or combine runs that employed different tools.

Request: Compare a group of runs with another group of runs

 curl -X GET https://{subdomain}.cop.blackduck.com/api/query/v1/issues?project-id[]={project_id}&run-id[]={run_id_A}&run-id[]={run_id_B}&compare-run-id[]={run_id_Y}&compare-run-id[]={run_id_Z}&page-limit=10
-H "accept: application/vnd.api+json"
-H 'Authorization: Bearer {JWT}'

The request above would combine the two values for run-id into a set and the two values for compare-id into another set, resulting in (a, b) - (y, z). Note that the run-id attribute and the compare-run-id attribute have to be repeated for each new id that you want to include.

You can also use multiple entries to compare sets of branches or revisions, using the attributes as shown in the table above.