CI/CD Integration¶
Integrate TerraTidy into your CI/CD pipeline.
GitHub Actions¶
Use the official GitHub Action:
See GitHub Actions for full documentation.
Jenkins¶
pipeline {
agent any
stages {
stage('Terraform Quality') {
steps {
sh 'go install github.com/santosr2/TerraTidy/cmd/terratidy@latest'
sh 'terratidy check --format junit > terratidy-results.xml'
}
post {
always {
junit 'terratidy-results.xml'
}
}
}
}
}
GitLab CI¶
terratidy:
image: ghcr.io/santosr2/terratidy:v0.2.0-alpha.4
stage: validate
script:
- terratidy check --format junit > terratidy-results.xml
artifacts:
reports:
junit: terratidy-results.xml
rules:
- changes:
- "**/*.tf"
- "**/*.hcl"
Bitbucket Pipelines¶
pipelines:
pull-requests:
'**':
- step:
name: TerraTidy
image: golang:1.26.1
script:
- go install github.com/santosr2/TerraTidy/cmd/terratidy@latest
- terratidy check --format text
CircleCI¶
version: 2.1
jobs:
terratidy:
docker:
- image: ghcr.io/santosr2/terratidy:v0.2.0-alpha.4
steps:
- checkout
- run:
name: TerraTidy Check
command: terratidy check --format text
workflows:
validate:
jobs:
- terratidy
Docker-Based CI¶
For any CI system, use the Docker image:
Output Format Selection¶
Choose the output format based on your CI system:
| CI System | Recommended Format | Why |
|---|---|---|
| GitHub Actions | github | Inline PR annotations |
| Jenkins | junit | JUnit plugin integration |
| GitLab CI | junit | Built-in artifact reports |
| Any CI | json | Machine-readable, scriptable |
| PR comments | markdown | Human-readable summaries |
| Code scanning | sarif | GitHub/GitLab security tab |
Best Practices¶
- Use
--changedfor PR checks to only validate modified files - Use
--parallelfor full scans to speed up CI runs - Pin the version to avoid surprises from upgrades
- Use profiles for different CI stages (fast PR check vs thorough merge gate)
- Upload SARIF for GitHub Code Scanning integration
- Fail on errors only with
--severity-threshold errorfor lenient checks