Code Insights is a feature added in Bitbucket Server 5.15.
It surfaces information relevant to a pull request, so the author and reviewers are able to make better informed decisions. Information supplied could include:
- static analysis reports
- security scan results
- artifact links
- unit tests
- build status
It includes an API, and a UI so apps created by a third-party can supply data to be surfaced on the pull requests.
The information comprises two parts; annotations and reports.
Integrations can be built to send data to pull requests. Integrations that have been built by third-parties can be found in the Atlassian marketplace.
Building an integration: resources
If you're looking to build your own integration, we have some tutorials available on Atlassian's developer documentation site.
If you are interested in adding Code Insights as part of your CI pipeline, here is a very helpful resource.
If you're wanting a more comprehensive overview of the feature and how it works, try the how to add code insights to pull requests tutorial.
Quality reports and annotations
The generated reports show summary information sent by any integration to Bitbucket Server for your branch. They can also be run against your branch without sending a report.
Reports can contain:
- a description
- a link back to the reporter’s URL
- up to 6 fields for displaying data
- the annotations attached to the report (if there are any).
Annotations show specific information on a given line in the pull request, and must be attached to a report.
Annotations are shown on the unified diff view, and on reports. They are not shown on side-by-side diff, commit diffs, or iterative diff.
You can see annotations on:
- changed lines, or
- lines added in the pull request.
This ensures that there is not too much noise from annotations that are not relevant to you.
Annotations are only displayed on the diff if the target has not also changed the file.
For files that have been changed by the target branch, we cannot accurately place annotations, as the annotated line may have been pushed down to a different line, by changes made by the target branch.
When this happens, the annotations are displayed in a separate dialog you can open, by clicking the icon button in the toolbar.
If you need to work without annotations enabled, you can hide them by using keyboard shortcut shift + a or:
- open the more (...) menu in the top right
- clear the show annotations option in the menu.
If you are seeing a message stating that the annotations are possibly obsolete, this is an issue unique to Code Insights.
This message means there is a possibility that both the target and source for a pull request, changed the same file.
Bitbucket Server doesn’t check in what way the file has been changed, so it’s possible the annotation is still valid, but also possible that it is not.