Skip to content

CRken GitLab Integration

🚀 Quick start

  1. Create a new GitLab webhook at your project.
  2. Set the webhook URL that towards to the following URL:
    https://crken-code-review.p.rapidapi.com/gitlab-review
    
  3. Define the following headers:
    • X-RAPIDAPI-KEY with your API key provided to you by the RapidAPI.
    • X-A4A-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 you to create project or group token giving it a nice name, such as CRken Code Reviewer, because code review comments will be authored by GitLab Bot under this name.

  4. Set trigger to Merge Request events.

Webhook main configuration

  1. Create a new GitLab webhook at your project.
  2. Set the webhook URL that towards to the following URL:
    https://crken-code-review-chatgpt.p.rapidapi.com/gitlab-review
    
  3. Define the following headers:
    • X-RAPIDAPI-KEY with your API key provided to you by the RapidAPI.
    • X-A4A-OPENAI-API-KEY with your API key for OpenAI.
    • X-A4A-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 you to create project or group token giving it a nice name, such as CRken Code Reviewer, because code review comments will be authored by GitLab Bot under this name.

  4. Set trigger to Merge Request events.

Webhook main configuration

That's it. Now, each time you open a Merge Request or update files within the Merge Request, CRken will automatically review the changes.

🪝 Webhook URL

The endpoint with query parameters for the code review webhook is:

https://crken-code-review.p.rapidapi.com/gitlab-review
https://crken-code-review-chatgpt.p.rapidapi.com/gitlab-review

This endpoint responds quickly and schedule the actual review in the internal processing queue.

🔌 Events

GitLab allows you to enable triggering a webhook via various types of events. CRken webhook support the following two types:

Comments events

When the Comments event is enabled, CRken will review changes in Merge Requests if someone leaves a comment containing /crken (the trigger word is configurable if necessary).

Webhook Comments events configuration

Depending on where the comment is left, CRken will review changes in a single specific file or changes in all target files:

  • If the comment is made anywhere in the thread related to changes in a specific file, only that file will be reviewed.
  • If the comment is made in the Merge Request outside of the specific file thread, then all "target" files will be reviewed.

Merge Request events

When the Merge Request event is enabled, CRken will automatically review changes in "target" files each time a Merge request is created or the code in the Merge Request is updated.

Webhook Merge Request events configuration

🛠 Configuration

Most of the parameters can be configured in two ways:

  1. Via HTTP headers.
  2. Via the configuration file .crken.yml in the root of your repository. Example:
    target: '\.(py|c|h|cpp|hpp|java|php|go|cs|sh|(j|t)sx?|md|tf|vue)$'
    language: English
    

We recommend:

  • Set all secrets (API keys and tokens) via headers.
  • All other parameters via the configuration file .crken.yml.

API key ⭐

Set webhook header X-RAPIDAPI-KEY to your API key provided to you by the RapidAPI.

RapidAPI API key ⭐

⚠️ Note: The CRken API does not require you to provide your OpenAI API key. If you prefer to use your own OpenAI API key, you can opt for the alternative CRken ChatGPT API.

⚠️ Note: The CRken ChatGPT API requires providing your OpenAI API key. If you are uncomfortable registering on OpenAI or providing an API key, you can use the alternative CRken API. CRken API will incur additional costs.

Bring Your Own License (BYOL) ChatGPT variant is the preferred option for cases where you would like to use your own OpenAI account, giving you full control over your API usage and billing. It can also be a good choice if you are already utilizing ChatGPT for other projects.

Set webhook header X-A4A-OPENAI-API-KEY to your API key provided to you by the OpenAI.

GitLab token ⭐

CRken needs the GitLab access token (for project or group). The token must have at least developer-level permissions with the "api" scope.

💡 Tip: We recommend you to create project or group token giving it a nice name, such as CRken Code Reviewer, because code review comments will be authored by GitLab Bot under this name.

Define header X-A4A-GITLAB-TOKEN in webhook's settings.

GitLab host

Normally, you don't need to set the GitLab host since it can be obtained from the payload that GitLab posts automatically. However, in some cases (e.g., sophisticated network setup), you may wish to set it explicitly.

Define header X-A4A-GITLAB-HOST in webhook's settings if necessary.

Review target settings

Target ⭐

The "target" defines a regex pattern for matching files.

By default, the "target" is set to the \.(py|c|h|cpp|hpp|java|php|go|cs|sh|(j|t)sx?|md|tf|vue)$ regex which enables the review for the following languages:

  • Bash/Shell
  • C#
  • Java
  • C/C++
  • JavaScript/TypeScript
  • Go
  • Python
  • PHP

Ways to redefine the the "target":

  • Header X-A4A-TARGET in webhook settings.
  • Property target in the YAML configuration file .crken.yml in the root of your repository.

Extra target

The "extra target" defines an additional regex pattern for matching files. Useful if you don't want to redefine the "target" completely.

By default, the "extra target" regex is empty.

Ways to define the the "extra target":

  • Header X-A4A-TARGET-EXTRA in webhook settings.
  • Property target-extra in the YAML configuration file .crken.yml in the root of your repository.

Exclude from target

The "exclude from target" defines a regex pattern to exclude files from review (even if they are matched by the "target" or "extra target"). Useful if you don't want to redefine the "target" or "extra target".

By default, the "exclude from target" regex is empty.

Ways to define the the "extra target":

  • Header X-A4A-TARGET-EXCLUDE in webhook settings.
  • Property target-exclude in the YAML configuration file .crken.yml in the root of your repository.

Review language

By default, review comments will be produced in English (recommended for best quality).

Ways to redefine the the "language":

  • Header X-A4A-LANGUAGE in webhook settings.
  • Property language in the YAML configuration file .crken.yml in the root of your repository.