BeeCR CI/CD job component (GitLab 17+)
⚠️ Note: This section describes how to set up code review as a GitLab CI/CD component (generally available in GitLab 17). If you are looking to set up code review in a "legacy" way via templates, please refer to the "CI/CD job template" document. If you prefer not to use CI/CD at all, please refer to the alternative integration method via "Webhook".
🚀 Quick start
- Define the following CI/CD variables in your project (or group or GitLab instance):
BEECR_API_KEY
with an API key provided to you by the BeeCR team.BEECR_GITLAB_TOKEN
with your GitLab access token (project or group). The token must have at least developer-level permissions with the "api" scope.💡 Tip: We recommend giving it a nice name, such as
BeeCR Code Reviewer
, because code review comments will be authored by GitLab Bot under this name.
- In your project's settings, make sure that CI/CD is enabled and that at least one GitLab runner is available.
- Create (or modify if it exists) a
.gitlab-ci.yml
file in the root of your repository by adding a review stage to the stages definition and including thebeecr
component using theinclude
keyword.
- Define the following CI/CD variables in your project (or group or GitLab instance):
- In your project's settings, make sure that CI/CD is enabled and that at least one GitLab runner is available.
- Create (or modify if it exists) a
.gitlab-ci.yml
file in the root of your repository by adding a review stage to the stages definition and including thebeecr
component using theinclude
keyword.
📄 Conventions
- The job runs only for merge requests.
- Review results are added as comments to the files.
- If the commit message contains any of message includes one of:
[no_review]
,[skip_review]
,[no review]
,[skip review]
,[no-review]
,[skip-review]
,[mute]
,
:no_review:
,:skip_review:
,:no review:
,:skip review:
,:no-review:
,:skip-review:
,:mute:
,
the review job is not triggered.
🛠 Configuration
Credentials
Credentials for the code review job can be configured via environment variables. The following variables have to be defined:
💡 Tip: GitLab provides two alternative ways to set variables:
- Extend the included job definition by deep merging. This means that the configuration of an included job can be performed by declaring a local job with the same name and redefining options.
- Set CI/CD Variables in the GitLab UI settings for a project, group, or even a GitLab instance (if you use a self-hosted solution).
We recommend setting variables that contain secret information (API keys, tokens, etc.) via the GitLab settings and enabling "mask mode" for them to prevent leakage.
Other options
See the following lists for the input options that influence jobs defined in this CI/CD component:
url
defines the BeeCR Code Review service url.
By default, the url ishttps://beecr.io/api/v1
.stage
defines the stage at which the job will be executed.
By default, the stage isreview
.when
defines whether the job will be executed manually or not.
Use "manual" to make the review job runs manually.
Default is "always".target
defines a regex pattern for matching files.
By default, the target regex is\.(py|c|h|cpp|hpp|cs|java|kt|swift|php|go|sh|(j|t)sx?)$
which enables the review for files with the following languages:- Python
- C/C++
- C#
- Java
- Kotlin
- Swift
- PHP
- Go
- Bash/Shell
- JavaScript/Typescript
target-extra
defines an additional regex pattern for matching files. Useful if you don't want to redefinetarget
.
By default, it is empty.target-exclude
defines a regex pattern to exclude files from review (even if they are matched bytarget
ortarget-extra
). Useful if you don't want to redefinetarget
.
By default, it is empty.language
defines the review language.
By default, review comments will be produced inEnglish
.
Example
Example of configuration:
stages:
- review
include:
- component: gitlab.com/cvisionlab/beecr/beecr@1.4.2
inputs:
target-extra: '\.json$'
▶️ Manual execution
For some reasons, you may wish to control the code review job execution manually. For those purposes, simply set value manual
to the when
input option:
📌 Pin/unpin version
All the examples above refer to a specific CI/CD job version. If you wish to refer to the latest version, simply use main
in the component URL instead of the specific release tag (e.g., 1.4.2
). Example: