BeeCR CI/CD job template (legacy)
⚠️ Note: This section describes how to set up code review in a "legacy" way. If you are looking to set up code review as a GitLab CI/CD component (generally available in GitLab 17), please refer to the "CI/CD job component" document. If you prefer not to use CI/CD at all, please refer to the alternative integration method via "Webhook" document.
🚀 Quick start
- Define the following CI/CD variables in your project (or group or GitLab instance) settings:
BEECR_API_KEYwith an API key provided to you by the BeeCR team.BEECR_GITLAB_TOKENwith 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.ymlfile in the root of your repository by adding a review stage to the stages definition and including thebeecrtemplate using theincludekeyword.
- Define the following CI/CD variables in your project (or group or GitLab instance) settings:
- 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.ymlfile in the root of your repository by adding a review stage to the stages definition and including thebeecrtemplate using theincludekeyword.
📄 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
The code review job can be configured via environment variables in two alternative ways:
- 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).
- 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.
💡 Tip: We recommend setting variables that contain secret information (API keys, tokens, etc.) via the GitLab UI settings and enabling "mask mode" for them to prevent leakage.
See the following lists for the settings that influence jobs defined in this template.
Credentials
Credentials for the code review job can be configured via environment variables. The following variables have to be defined:
Other options
BEECR_URLdefines the BeeCR Code Review service url.
By default, the url ishttps://beecr.io/api/v1.BEECR_TARGETdefines 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
BEECR_TARGET_EXTRAdefines an additional regex pattern for matching files. Useful if you don't want to redefineBEECR_TARGET.
By default, it is empty.BEECR_TARGET_EXCLUDEdefines a regex pattern to exclude files from review (even if they are matched byBEECR_TARGETorBEECR_TARGET_EXTRA). Useful if you don't want to redefineBEECR_TARGET.
By default, it is empty.BEECR_LANGUAGEdefines the review language.
By default, review comments will be produced inEnglish.
💡 Tip: When you define CI/CD variables via the UI, pay attention to the "Expand variable reference" option (which is enabled by default). It may cause undesired behavior when the $ character is used in the value (which is common, for example, if your value is a RegEx pattern).
Example
Example of configuration by deep merging:
stages:
- review
include:
- remote: 'https://gitlab.com/cvisionlab/beecr/-/raw/1.4.2/templates/beecr/template-always.yml'
beecr:
variables:
BEECR_TARGET_EXTRA: '\.json$'
▶️ Manual execution
For some reasons, you may wish to control the code review job execution manually. For those purposes, simply include the template-manual.yml file instead of template-always.yml:
stages:
- review
include:
- remote: 'https://gitlab.com/cvisionlab/beecr/-/raw/1.4.2/templates/beecr/template-manual.yml'
📌 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 template URL instead of the specific release tag (e.g., 1.4.2). Example: