pylint-gitlab provides custom Pylint formatters for seamless integration with GitLab CI/CD, enabling the generation of Code Quality reports and GitLab Pages HTML reports from Pylint's linting results. The current version is 2.1.1, released in November 2025, and the project has an active, though somewhat irregular, release cadence.
pip install pylint-gitlabVerified import paths — ran on the pinned version, not inferred.
This GitLab CI/CD configuration demonstrates how to integrate `pylint-gitlab` into your pipeline. It installs the library, creates a dummy Python file with a simple linting issue, runs Pylint using the `GitlabCodeClimateReporter` to generate a `codeclimate.json` file, and then declares this file as a `codequality` artifact, which GitLab will parse to display code quality metrics in merge requests.
Consider migrating to 'ruff' which has built-in support for GitLab Code Quality reports. Refer to 'ruff' official documentation for migration guidance.
Ensure all project dependencies are installed in the CI environment (e.g., using `pip install -r requirements.txt`). If your project structure involves custom import paths, add them to `sys.path` using `init-hook` in your `.pylintrc` or by manipulating `PYTHONPATH` in your CI script.
Include `--exit-zero` in your Pylint command within the CI script (e.g., `pylint --exit-zero ...`) to ensure the job completes and generates the artifact. If you want the pipeline to fail on a specific Pylint score, configure GitLab CI/CD's quality gates or use a custom script to evaluate the Pylint score output.
Add an `artifacts` section to your CI job with `reports: codequality: codeclimate.json` (or your chosen output filename) to ensure the report is collected and processed by GitLab.
Verify the Python version used in your CI image (e.g., `python:3.10-slim`) is compatible with the Pylint version implicitly or explicitly installed. Check Pylint's release notes for its minimum Python requirements.
Ensure `pylint` and `pylint-gitlab` are installed in your CI/CD environment (e.g., via `pip install pylint pylint-gitlab`). If using a virtual environment, make sure it's activated, or the full path to the executables is used.
Install all project dependencies in your CI/CD job (e.g., `pip install -r requirements.txt`). Additionally, ensure that your project's root directory is added to Python's path before running Pylint, typically by setting `export PYTHONPATH=$PYTHONPATH:./src` (adjust `src` to your project's source directory) or running Pylint from the project's root.
Run Pylint with the correct formatter and redirect output to the expected file. In your `.gitlab-ci.yml`, the script should look like: `pylint --output-format=pylint_gitlab.GitlabCodeClimateReporter > gl-code-quality-report.json`. Then, declare this file as a `codequality` artifact: `artifacts: reports: codequality: gl-code-quality-report.json`.