Exit Codes
pgvet uses standard exit codes to communicate results:- 0: No issues found - all SQL passed analysis
- 1: Issues found (warnings or errors)
- 2: Fatal error (parse failure, file not found, etc.)
JSON Output Format
Use--format json to get machine-readable output for parsing in CI systems:
Filtering by Severity
To fail the build only on errors (not warnings), parse the JSON:GitHub Actions
Basic Integration
Add a workflow file at.github/workflows/sql-lint.yml:
With Annotations
Create inline annotations on your PR using the JSON output:Fail on Errors Only
GitLab CI
Add to.gitlab-ci.yml:
Code Quality Report
Convert pgvet output to GitLab’s Code Quality format:Jenkins
Add to yourJenkinsfile:
CircleCI
Add to.circleci/config.yml:
Pre-commit Hook
For local enforcement before pushing, add.pre-commit-config.yaml:
.git/hooks/pre-commit:
Tips
- Cache pgvet binary in CI to speed up builds
- Run only on changed files using
git diffto filter paths - Use rule selection (
--rulesor--exclude) to customize checks per project - Store JSON artifacts for trend analysis over time
- Set up notifications (Slack, email) when errors are found in main branch