How do you run Checkov in a CI pipeline?
BeginnerHands-onCheckov
Answer
Short answer
Add a Checkov step that scans the IaC folders on every PR and fails the job when checks fail (Checkov exits non-zero by default). Output SARIF or JUnit so results show in the PR, and use --soft-fail-on / --hard-fail-on to control which severities block.
GitHub Actions
- uses: actions/checkout@v4
- name: Checkov
uses: bridgecrewio/checkov-action@v12
with:
directory: infra/
framework: terraform,kubernetes
output_format: cli,sarif
output_file_path: console,results.sarif
soft_fail: false
- uses: github/codeql-action/upload-sarif@v3
if: always()
with: { sarif_file: results.sarif }
GitLab CI
checkov:
stage: test
image: { name: bridgecrew/checkov:latest, entrypoint: [""] }
script:
- checkov -d infra/ --compact -o cli -o junitxml --output-file-path console,checkov.xml
artifacts: { reports: { junit: checkov.xml }, when: always }
Jenkins
stage('IaC scan') {
steps { sh 'checkov -d infra/ --compact --quiet' }
}
Rolling out to an existing codebase
Start with --soft-fail (report only) or a baseline (checkov -d . --create-baseline, then --baseline .checkov.baseline), fix gradually, then enforce.
What to say in the interview
"Checkov runs on every PR against infra folders; failures exit non-zero and block the merge. SARIF or JUnit output surfaces findings in the PR, and for legacy code we start with soft-fail or a baseline so only new issues block."
More on Checkov
What is Checkov and how do you scan Terraform with it?BeginnerWhat is IaC security scanning and why is it needed?BeginnerWhat is Checkov?BeginnerHow do you scan Terraform code with Checkov?BeginnerWhy scan the Terraform plan with Checkov instead of only the .tf files?IntermediateHow do you scan Kubernetes manifests and Dockerfiles with Checkov?Beginner