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
- Navigate to Codity Settings → Providers → GitLab
- Click "Connect GitLab"
- You'll be redirected to GitLab to authorize Codity
- Sign in with your GitLab credentials
- Grant Codity the requested permissions
- You'll be redirected back to Codity
Step 2: Create a Personal Access Token
- Go to GitLab → Settings → Access Tokens (or visit
https://gitlab.com/-/profile/personal_access_tokens) - Click "Add new token"
- 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 accessread_repository- Read repository contentswrite_repository- Create branches and commits (for test generation)read_user- Read user information
- Click "Create personal access token"
- Copy the token immediately - you won't be able to see it again
Step 3: Configure Token in Codity
- Return to Codity Settings → Providers → GitLab
- Paste your Personal Access Token into the "GitLab Token" field
- If using a self-hosted GitLab instance, enter your GitLab API URL (e.g.,
https://gitlab.yourcompany.com/api/v4) - Click "Save" to store the token
Step 4: Enable Repositories
- Navigate to Repositories → Add Repository
- Select GitLab as your provider
- Choose the repositories (projects) you want to enable for code reviews
- Click "Enable" for each repository
Step 5: Verify Setup
- Create a test merge request in one of your connected repositories
- Wait 1-3 minutes for Codity to analyze the MR
- Check the MR comments to see Codity's review feedback
Self-Hosted GitLab Setup
If you're using a self-hosted GitLab instance:
- 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
- Format:
- Network Requirements: Ensure your GitLab instance is accessible from the internet (or from Codity's servers if using a private network)
- SSL Certificate: Your GitLab instance must have a valid SSL certificate
- Same Features: Self-hosted GitLab supports the same features as GitLab.com
Best Practices
- Set appropriate token expiration: Use 90-day expiration for balance of security and convenience
- Rotate tokens proactively: Update tokens 1-2 weeks before expiration to avoid downtime
- Use descriptive token names: Name tokens clearly (e.g., "Codity Production - Expires 2024-03-15")
- Monitor token usage: Periodically review active tokens in GitLab and revoke unused ones
- Document token expiration dates: Keep track of when tokens expire to plan rotations
- Test after token updates: After updating a token, create a test MR to verify everything works
- Use group tokens when possible: For group repositories, consider using group-level tokens for better management
Next Steps
- Learn about GitHub setup
- Learn about Azure DevOps setup
- Learn about Bitbucket setup
- Learn about JIRA Integration for connecting JIRA tickets to PR reviews
- Check the Getting Started Guide for general setup instructions