6.3.4.5. AnnotateGitLabPR

Annotate issue violations on GitLab merge requests

This rule generates reports for GitLab merge requests 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 the documentation section "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.
 

code_quality_default_severity

code_quality_default_severity : GitlabSeverity = 'MINOR'

Default severity to use in code quality reports for issues that have an unknown severity.
 

code_quality_report_filename

code_quality_report_filename : bauhaus.analysis.config.ProjectRelativePath | None = None

The name of the file containing the generated Code Quality report. Only used if the report type is code_quality.
 

code_quality_severity_map

code_quality_severity_map

Type: dict[str, GitlabSeverity]

Default:

{
   'advisory': 'INFO',
   'document': 'INFO',
   'error': 'CRITICAL',
   'high': 'CRITICAL',
   'low': 'MINOR',
   'mandatory': 'BLOCKER',
   'medium': 'MAJOR',
   'required': 'BLOCKER',
   'warning': 'MAJOR'
}
Map Dashboard severities to a GitLab Code Quality severities. Only used if the report type is code_quality. Can be passed multiple times.
 

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.
 

general_options

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

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.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. Does not apply to "inline" comments, i.e., comments left on a specific line of a file.
 

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 manual section '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.

 

merge_request_iid

merge_request_iid : str | None = '$(GITLAB_MERGE_REQUEST_IID=)'

Internal ID of the merge request.
 

project

project : str = '$(GITLAB_PROJECT)'

ID or path (i.e., myproject/myrepository) of the GitLab project.
 

report_type

report_type : GitlabReportType = 'DISCUSSION_NOTES'

The type of report to generate.
 

server

server : str = 'https://gitlab.com'

URL to target GitLab instance.
 

token

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

GitLab access token.
 

warning_exit_code

warning_exit_code : int = 0

The exit code to use if any warning is emitted while running annotate_pr. You can use the allow_failure: section in your GitLab CI configuration file to set up this exit code as one that denotes a warning rather than an error. By default, exit code will not be changed for warnings (equivalent to setting this to 0).
 

Option Types

These types are used by options listed above:

GitlabReportType

An enumeration.
 

DISCUSSION_NOTES

Leaves a resolvable discussion comment for each annotation.

REGULAR_NOTES

Leaves a comment for each annotation.

CODE_QUALITY

Generates a Code Quality report, refer to the GitLab documentation for more information.

NOTES

Deprecated: Use DISCUSSION_NOTES instead.

GitlabSeverity

An enumeration.
 
  • INFO

  • MINOR

  • MAJOR

  • CRITICAL

  • BLOCKER

IssueKind

An enumeration.
 
  • 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.