GitLab Integration
Follow this guide to integrate Lintify with your GitLab repository using GitLab CI/CD.
Configuration Steps
1. Add GitLab CI Configuration
Create or update your .gitlab-ci.yml
file in your repository with the following content:
lintify:
image: docker:latest
services:
- docker:dind
script:
- git fetch origin ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}
- git diff origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME} -- > diff.txt
- docker run --rm \
-e PLATFORM=gitlab \
-e API_TOKEN=${CI_JOB_TOKEN} \
-e PROJECT_URL=${CI_PROJECT_URL} \
-e MERGE_REQUEST_ID=${CI_MERGE_REQUEST_IID} \
-v $PWD/diff.txt:/app/diff.txt \
lintify-image:latest analyze --diff /app/diff.txt
only:
- merge_requests
2. Configure GitLab Variables
The pipeline uses the following variables that are automatically provided by GitLab CI:
CI_JOB_TOKEN
- Automatically provided by GitLab CICI_PROJECT_URL
- Your project's URLCI_MERGE_REQUEST_IID
- Merge request ID
Note: These variables are automatically available in merge request pipelines. You don't need to configure them manually.
3. Customize the Configuration
You can customize the pipeline by modifying:
- Runner configuration: Use specific GitLab runners
- Docker image: Specify a Lintify version
- Pipeline triggers: Add more pipeline events
How It Works
- When a merge request is created or updated, the pipeline automatically triggers.
- The job generates a diff between the source and target branches.
- Lintify analyzes the changes and posts comments directly on your merge request.
Troubleshooting
Common issues and their solutions:
Docker service issues
Ensure your GitLab runner has Docker-in-Docker (dind) service enabled.
Permission errors
Verify that the CI_JOB_TOKEN
has sufficient permissions to post comments.
Need More Help?
If you're experiencing issues with the GitLab integration, our support team is here to help.