What Is Trivy?
Trivy is an open-source, all-in-one security scanner from Aqua Security. It can analyze:- Container images
- File systems
- Git repositories
- Kubernetes manifests
- Infrastructure as Code (IaC)

Installing Trivy
You can install Trivy via package managers, a standalone binary, or run it in Docker.Homebrew (macOS)
Docker
RPM-Based Linux
Manual / From Source
Basic Usage
Scan a Docker image for vulnerabilities:By default, Trivy exits with code
0 even if it finds non-critical issues. Use --exit-code to control build failures based on severity.Integrating Trivy into a Jenkins Pipeline
Add a Trivy Vulnerability Scanner stage immediately after your Docker build. Below is an example declarative pipeline:The critical-scan stage uses
--exit-code 1. Any CRITICAL vulnerability will fail the build immediately.Supported Reporting Formats
Trivy supports several output formats:
Templates are installed at:

Reviewing Scan Results
After your Jenkins job completes, the workspace will contain:
- trivy-image-medium.html / .json / .xml
- trivy-image-critical.html / .json / .xml

Adjusting Severity Thresholds
To treat HIGH severity like MEDIUM (only fail on CRITICAL), include HIGH in the non-failing scan:Summary
In this tutorial, you learned how to:- Install Trivy on various platforms
- Execute basic vulnerability scans on images and filesystems
- Integrate Trivy into a Jenkins pipeline with pass/fail thresholds
- Convert JSON results to HTML, JUnit, or CycloneDX formats
- Publish and review vulnerability reports in Jenkins