diff --git a/Usage.md b/Usage.md index a84f854e..c2f91bd0 100644 --- a/Usage.md +++ b/Usage.md @@ -6,6 +6,7 @@ - [Online Usage](#online-usage) - [GitHub App](#working-with-github-app) - [GitHub Action](#working-with-github-action) +- [GitLab Webhook](#working-with-gitlab-webhook) - [BitBucket App](#working-with-bitbucket-self-hosted-app) - [Azure DevOps Provider](#azure-devops-provider) - [Additional Configurations Walkthrough](#appendix---additional-configurations-walkthrough) @@ -237,6 +238,16 @@ For example, you can set an environment variable: `pr_description.add_original_u [pr_description] add_original_user_description = false ``` +### Working with GitLab Webhook +After setting up a GitLab webhook, to control which commands will run automatically when a new PR is opened, you can set the `pr_commands` parameter in the configuration file, similar to the GitHub App: +``` +[gitlab] +pr_commands = [ + "/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true", + "/review --pr_reviewer.num_code_suggestions=0", + "/improve", +] +``` ### Working with BitBucket Self-Hosted App Similar to GitHub app, when running PR-Agent from BitBucket App, the default [configuration file](pr_agent/settings/configuration.toml) from a pre-built docker will be initially loaded. diff --git a/pr_agent/servers/gitlab_webhook.py b/pr_agent/servers/gitlab_webhook.py index 6be3ae45..435d6967 100644 --- a/pr_agent/servers/gitlab_webhook.py +++ b/pr_agent/servers/gitlab_webhook.py @@ -32,7 +32,7 @@ def handle_request(background_tasks: BackgroundTasks, url: str, body: str, log_c async def _perform_commands_gitlab(commands_conf: str, agent: PRAgent, body: dict, api_url: str, log_context: dict): apply_repo_settings(api_url) - commands = get_settings().get(f"azure_devops_server.{commands_conf}") + commands = get_settings().get(f"gitlab.{commands_conf}") for command in commands: split_command = command.split(" ") command = split_command[0] diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 744213da..8d977e7a 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -171,17 +171,12 @@ push_commands = [ ] [gitlab] -# URL to the gitlab service -url = "https://gitlab.com" - -# Polling (either project id or namespace/project_name) syntax can be used -projects_to_monitor = ['org_name/repo_name'] - -# Polling trigger -magic_word = "AutoReview" - -# Polling interval -polling_interval_seconds = 30 +url = "https://gitlab.com" # URL to the gitlab service +pr_commands = [ + "/describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true", + "/review --pr_reviewer.num_code_suggestions=0", + "/improve --pr_code_suggestions.summarize=true", +] [bitbucket_app] #auto_review = true # set as config var in .pr_agent.toml