6.3.4.1. AnnotateBitbucketCloudPR

Annotate issue violations on Bitbucket Cloud pull request

This rule generates reports for Bitbucket Cloud pull request using Axivion Dashboard data as a basis.

Reports are either posted as comments to a pull request or as inline code review annotations (Git-platform-specific rules may offer additional output formats).

Findings are retrieved from the source configured in /Results/Dashboard. In managed_upload mode, a connection to the Dashboard is established via its REST API (access tokens and username/password authentication are supported). In shared_database mode, the SQLite database is accessed directly.

Instead of triggering this behavior via a rule, you can alternatively get the same functionality by calling the command-line annotate_pr tool.

Refer to 6.4.8 Generating review comments with annotate_pr for more details.

Options

The following places define options that affect this rule: PostCIActions

abort_on_error

abort_on_error : bool = False

Whether the CI run should be aborted if this action fails.
 

default_severity

default_severity : BitbucketSeverity = 'MEDIUM'

Default severity to use for issues that have an unknown severity.
 

delete_reports

delete_reports : bool = False

Utility flag to delete all Axivion-made reports in the current commit. When this is set to true, no other action will be taken except to delete the reports.
 

failure_exit_code

failure_exit_code : int = 1

The exit code to return from the CI run on failure if abort_on_error is True.
 

fixed_report_key

fixed_report_key : bool = False

For annotation reports, use the fixed key axivion-suite instead of axivion-suite- followed by a random UUID. If you set this, any previous report will be deleted first, since the report key has to be unique within a PR.
 

general_options

General options that are not dependent on the Git platform to which the report is made.
 

general_options.fail_if_issues_exist : bool = False

When enabled, the presence of at least one reported issue (or an issue that would be reported, if skip_report is set) counts as a failure of this rule.

Whether such a failure actually aborts the CI run (and with which exit code) is then controlled by this rule's abort_on_error and failure_exit_code options.

 

general_options.include_suppressed : bool = False

Whether suppressed issues shall be included in the report.
 

general_options.issue_kinds

Type: set[IssueKind]

Default: {'Architecture Violations', 'Clones', 'Cycles', 'Dead Entities', 'Metric Violations', 'Style Violations'}

Issue kinds which shall be included in the report.
 

general_options.json_export : bauhaus.analysis.config.ProjectRelativePath | None = None

Path to a JSON file that the findings should also be exported to. Note that even if skip_report is set, the JSON export will still run, if specified.

The JSON output created by this option can be used as input for the Azure DevOps Extension.

 

general_options.keep_issues : KeepIssuesChoice = 'INSIDE_DIFF'

Configure whether to report only issues that are inside changed lines, outside changed lines, or whether to include all kinds of issues.
 

general_options.markdown_checkbox : bool = False

Prepend each reported issue with a checkbox in the report.
 

general_options.max_issues_per_kind : int = 20

Maximum number of issues per kind to be included in a single comment. Only applies when report_as_one_comment is set.
 

general_options.report_as_one_comment : bool = False

Report issues in a single comment posted to the Git platform when this is true. Otherwise, when this is false, issues will be left as individual code review notes.
 

general_options.skip_report : bool = False

Whether the reporting step shall be skipped. In this case, nothing will be reported to the Git platform.
 

general_options.start_revision : str = 'latest-1'

The baseline version in the Dashboard to compare the current version to. Refer to 7.2.1.18 Version Strings for an overview of possible values.
 

general_options.verbose : bool = False

Whether to enable verbose logging.

Note: When you use the --verbose/-v switch for axivion_ci, verbose mode will always be enabled.

 

no_annotations_warning

no_annotations_warning : bool = False

Disable the warning that appears when issues outside the diff are configured to be reported as annotations.
 

pull_request

pull_request : str = '$(BITBUCKET_CLOUD_PULL_REQUEST)'

ID of the target pull request.
 

report_type

report_type : BitbucketReportType = 'ANNOTATIONS'

Type of report to use.
 

repository

repository : str = '$(BITBUCKET_CLOUD_REPOSITORY)'

Slash-separated workspace and repository slug (i.e., foo/bar for repository 'bar' under project 'foo')
 

server

server : str = 'https://api.bitbucket.org/2.0'

URL to target Bitbucket Cloud instance.
 

severity_map

severity_map

Type: dict[str, BitbucketSeverity]

Default:

{
   'advisory': 'LOW',
   'document': 'LOW',
   'error': 'HIGH',
   'high': 'HIGH',
   'low': 'LOW',
   'mandatory': 'HIGH',
   'medium': 'MEDIUM',
   'required': 'MEDIUM',
   'warning': 'MEDIUM'
}
Map a Dashboard severity to a Bitbucket severity. Can be passed multiple times. Only used for report type ANNOTATIONS.
 

token

token : bauhaus.analysis.config.PasswordString = '$(BITBUCKET_CLOUD_TOKEN=**********)'

Bitbucket access token.
 

Option Types

These types are used by options listed above:

BitbucketReportType

ANNOTATIONS

Use the Reports API to create inline annotations.

COMMENTS

Create regular comments.

TASKS

Create task comments that act as blockers. Only supported in Bitbucket Server!

BitbucketSeverity

  • LOW

  • MEDIUM

  • HIGH

IssueKind

  • Architecture Violations

  • Clones

  • Cycles

  • Dead Entities

  • Metric Violations

  • Style Violations

KeepIssuesChoice

Whether to include issues inside or outside the diff.
 

INSIDE_DIFF

Include only issues inside the diff.

OUTSIDE_DIFF

Include only issues outside the diff.

ALL

Include all issues, whether inside or outside the diff.