GitLab
Learn more on how to setup Qodo Merge on GitLab.
Before you start
Installing Qodo Merge on GitLab allows you to enhance your merge requests with automated insights and improvements.
You can configure it for a single repository or roll it out to multiple projects or groups.
Setup time is usually a few minutes, depending on whether you’re using a webhook or CI pipeline approach.
After setup, Qodo Merge will monitor merge requests, process their content, and publish outputs like descriptions, reviews, or improvement suggestions directly to your MRs.
1. Log In to Qodo Portal
Before setting up Qodo Merge, make sure to create a Qodo account and sign in.
Once you've signed in to the Qodo Portal, you can follow the Qodo Merge installation guide straight from the portal, or continue reading here.
2. Setup Qodo Merge
Once you've signed in to your Qodo account, follow the instructions in the Qodo Portal or below to setup Qodo Merge on GitLab.
GitLab Repository
This installation method is available to subscribed users only.
Visit Qodo's Plans page to learn more.
Generate a GitLab access token: Generate either a personal, project or group level access token, and store the token in a safe place.
Make sure to enable the "api" scope in order to allow Qodo Merge to read pull requests, comment and respond to requests.

Generate a shared secret through Qodo Merge registration page:
Fill in your generated GitLab token and your company or personal name in the appropriate fields and click Submit.
A shared secret will be generated. Store it in a safe place.

Install a GitLab webhook:
Go to the settings menu in your repository or groups, and click Webhooks.
Click Add new webhook.
In the webhook definition form, fill in the following fields:
URL: https://pro.gitlab.pr-agent.codium.ai/webhook
Secret token: Your Qodo key
Trigger: Check the Comments and Merge request events boxes.
SSL Verification: Check the Enable SSL verification box.

You’re all set! Start using Qodo Merge.
GitLab Pipeline
Create a CI file: Create a new file named
.gitlab-ci.yml
with the content below:
stages:
- pr_agent
pr_agent_job:
stage: pr_agent
image:
name: codiumai/pr-agent:latest
entrypoint: [""]
script:
- cd /app
- echo "Running PR Agent action step"
- export MR_URL="$CI_MERGE_REQUEST_PROJECT_URL/merge_requests/$CI_MERGE_REQUEST_IID"
- echo "MR_URL=$MR_URL"
- export gitlab__url=$CI_SERVER_PROTOCOL://$CI_SERVER_FQDN
- export gitlab__PERSONAL_ACCESS_TOKEN=$GITLAB_PERSONAL_ACCESS_TOKEN
- export config__git_provider="gitlab"
- export openai__key=$OPENAI_KEY
- python -m pr_agent.cli --pr_url="$MR_URL" describe
- python -m pr_agent.cli --pr_url="$MR_URL" review
- python -m pr_agent.cli --pr_url="$MR_URL" improve
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
This script will run Qodo Merge on every new merge request.
You can modify the
rules
section to run Qodo Merge on different events.You can also modify the
script
section to run different Qodo Merge commands, or with different parameters by exporting different environment variables.
Add masked vairables: Go to CI/CD, then choose Variables. In the masked variables section, add the following masked variables to your GitLab repository:
GITLAB_PERSONAL_ACCESS_TOKEN
: Your GitLab personal access token.OPENAI_KEY
: Your OpenAI key.
Don't set the variables as
protected
, or the pipeline will not have access to them.
You’re all set! Start using Qodo Merge.
GitLab Webhook Server
Create a new GitLab user: In the group or project where you'd like to add Qodo Merge, create a new user and give it the Reporter role.
Generate token: Generate a
personal_access_token
withapi
access.Obtain secret: Generate a random secret for your app, and save it for later (
shared_secret
). For example, you can use:
SHARED_SECRET=$(python -c "import secrets; print(secrets.token_hex(10))")
Clone this repository:
git clone https://github.com/qodo-ai/pr-agent.git
Prepare variables and secrets:
In the Qodo Merge configuration file:
Set
config.git_provider
to "gitlab"
In the secrets file/variables:
Set your AI model key in the respective section
In the
[gitlab]
section:Set
personal_access_token
with the token from step 2.Set
shared_secret
with the random secret from step 3.
Build Docker image: Build a Docker image for the app. For example using Dockerhub:
docker build . -t gitlab_pr_agent --target gitlab_webhook -f docker/Dockerfile docker push codiumai/pr-agent:gitlab_webhook # Push to your Docker repository
Set the environmente variables in the Docker image:
CONFIG__GIT_PROVIDER=gitlab
GITLAB__PERSONAL_ACCESS_TOKEN=<personal_access_token>
GITLAB__SHARED_SECRET=<shared_secret>
GITLAB__URL=https://gitlab.com
OPENAI__KEY=<your_openai_api_key>
Create webhook: Create a webhook in your GitLab project. Make sure to:
Set the URL to
http[s]://<PR_AGENT_HOSTNAME>/webhook
Set the secret token to the generated secret from step 3.
Enable the triggers
push
,comments
andmerge request events
.
You’re all set! Start using Qodo Merge.
Last updated
Was this helpful?