
Attach trivy report on email (jenkins pipeline)
This is a simple steps to be followed to attach trivy report after docker build on jenkins pipeline to send on mail recipient.
Steps to be followed
- First trivy should be installed on the system: 
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/master/contrib/install.sh | sh -s -- -b /usr/bin- Pipeline script: 
pipeline {
    agent any
    
    stages {
        stage('Download trivy-redis report') {
            steps {
                sh 'trivy image redis > trivy_redis.txt'
            }
        }
    }
    post {
        always {
            archiveArtifacts artifacts: 'trivy_redis.txt', onlyIfSuccessful: true
            
                emailext attachLog: true, attachmentsPattern: 'trivy_redis.txt',
                body: "Trivy for redis has scanned.Please stay tuned for updates. More info at: ${env.BUILD_URL}",
                to: "abishek.kafle@hicare.in",
                subject: "Jenkins Build ${currentBuild.currentResult}: Job ${env.JOB_NAME}"
        }
    }
}
Now, we can download build log and trivy reports from email. 🎉
Last updated