GitLab Setup

This guide will help you set up Codity with GitLab to start reviewing merge requests automatically.

Prerequisites

  • A GitLab account (GitLab.com or self-hosted instance) with access to the repositories you want to connect
  • Ability to create Personal Access Tokens (PATs) in GitLab
  • Repositories must allow webhook creation

Setup Steps

Step 1: Sign In with GitLab OAuth

  1. Navigate to Codity Settings → Providers → GitLab
  2. Click "Connect GitLab"
  3. You'll be redirected to GitLab to authorize Codity
  4. Sign in with your GitLab credentials
  5. Grant Codity the requested permissions
  6. You'll be redirected back to Codity

Step 2: Create a Personal Access Token

  1. Go to GitLab → SettingsAccess Tokens (or visit https://gitlab.com/-/profile/personal_access_tokens)
  2. Click "Add new token"
  3. Configure the token:
    • Token name: "Codity Access" (or any descriptive name)
    • Expiration date: Set to 90 days (recommended) or your preferred duration
    • Select scopes: Check the following required scopes:
      • api - Full API access
      • read_repository - Read repository contents
      • write_repository - Create branches and commits (for test generation)
      • read_user - Read user information
  4. Click "Create personal access token"
  5. Copy the token immediately - you won't be able to see it again

Step 3: Configure Token in Codity

  1. Return to Codity Settings → Providers → GitLab
  2. Paste your Personal Access Token into the "GitLab Token" field
  3. If using a self-hosted GitLab instance, enter your GitLab API URL (e.g., https://gitlab.yourcompany.com/api/v4)
  4. Click "Save" to store the token

Step 4: Enable Repositories

  1. Navigate to RepositoriesAdd Repository
  2. Select GitLab as your provider
  3. Choose the repositories (projects) you want to enable for code reviews
  4. Click "Enable" for each repository

Step 5: Verify Setup

  1. Create a test merge request in one of your connected repositories
  2. Wait 1-3 minutes for Codity to analyze the MR
  3. Check the MR comments to see Codity's review feedback

Self-Hosted GitLab Setup

If you're using a self-hosted GitLab instance:

  1. Configure API URL: In Codity Settings → GitLab, enter your GitLab API URL:
    • Format: https://your-gitlab-instance.com/api/v4
    • Example: https://gitlab.company.com/api/v4
  2. Network Requirements: Ensure your GitLab instance is accessible from the internet (or from Codity's servers if using a private network)
  3. SSL Certificate: Your GitLab instance must have a valid SSL certificate
  4. Same Features: Self-hosted GitLab supports the same features as GitLab.com

Best Practices

  1. Set appropriate token expiration: Use 90-day expiration for balance of security and convenience
  2. Rotate tokens proactively: Update tokens 1-2 weeks before expiration to avoid downtime
  3. Use descriptive token names: Name tokens clearly (e.g., "Codity Production - Expires 2024-03-15")
  4. Monitor token usage: Periodically review active tokens in GitLab and revoke unused ones
  5. Document token expiration dates: Keep track of when tokens expire to plan rotations
  6. Test after token updates: After updating a token, create a test MR to verify everything works
  7. Use group tokens when possible: For group repositories, consider using group-level tokens for better management

Next Steps