Skip to main content
Installing Qodo on GitLab allows you to enhance merge requests with automated insights and improvements. You can configure Qodo for a single repository to start small, or roll it out across multiple projects or groups for broader adoption. Setup typically takes just a few minutes, depending on whether you are using a webhook-based or CI pipeline-based approach. Once configured, Qodo monitors merge requests, processes their content, and publishes actionable output, such as descriptions, reviews, and improvement suggestions, directly in your merge requests.

1. Log in to the Qodo portal

Before setting up Qodo, make sure you have created a Qodo account and signed in.

2. Set up Qodo on GitLab

After signing in to your Qodo account, follow the steps below to set up Qodo on GitLab.

GitLab Repository

This installation method is available to subscribed users only. Visit Qodo’s Plans page to learn more.
1

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 enable Qodo to read pull requests, comment and respond to requests.
2

Generate a shared secret through Qodo registration page:

a. Go to https://register.gitlab.pr-agent.codium.ai.
b. Enter your generated GitLab token and your company or personal name in the appropriate fields and click Submit.
c. A shared secret will be generated. Store it in a safe place.
3

Install a GitLab webhook:

a. Go to the Settings menu in your repository or groups, and click Webhooks.
b. Click Add new webhook.
c. In the webhook definition form, fill in the following fields:
You’re all set. You can now start using Qodo.
Visit Using Qodo in PRs to learn about next steps and how to get the most out of Qodo.

GitLab Pipeline

1

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 on every new merge request.
    • You can modify the rules section to run Qodo on different events.
    • You can modify the script section to run different Qodo commands, or with different parameters by exporting different environment variables**.**
Note:The $CI_SERVER_FQDN variable is available only from GitLab version 16.10.If you’re using an earlier version, you can combine the variables $CI_SERVER_HOST and $CI_SERVER_PORT to achieve the same result.
2

Add masked variables:

Go to CI/CD, then select 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 Open AI key.
Don’t set the variables as protected, or the pipeline will not have access to them.
You’re all set. You can now start using Qodo.
Visit Using Qodo in PRs to learn about next steps and how to get the most out of Qodo.

GitLab webhook server

1

Create a GitLab user

In the group or project where you want to add Qodo, create a new GitLab user and assign it the Reporter role.
2

Generate an access token

Generate a personal_access_token for this user with api access enabled.
3

Obtain a webhook secret

Generate a random secret for your application and save it for later use as the shared_secret. You can use any secure secret generation tool you prefer.
SHARED_SECRET=$(python -c "import secrets; print(secrets.token_hex(10))")
4

Clone this repository:

git clone https://github.com/qodo-ai/pr-agent.git
5

Prepare variables and secrets:

a. In the Qodo Merge configuration file:
  • Set config.git_provider to “gitlab”
b. 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.
6

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
7

Set the environmental 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>
8

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 and merge request events.
You’re all set. You can now start using Qodo.
Visit Using Qodo in PRs to learn about next steps and how to get the most out of Qodo.