2022-01-13 13:30:51 +00:00
|
|
|
pipeline {
|
2022-01-13 14:02:20 +00:00
|
|
|
// agent { node { label 'podman && trivy && aws' } }
|
2022-01-13 14:10:17 +00:00
|
|
|
agent { node { label 'podman' } }
|
2022-01-13 13:30:51 +00:00
|
|
|
stages {
|
2022-01-13 14:31:35 +00:00
|
|
|
// Build using rootless podman
|
2022-01-13 13:30:51 +00:00
|
|
|
stage('Build'){
|
|
|
|
steps {
|
|
|
|
sh 'make build'
|
|
|
|
}
|
|
|
|
}
|
2022-01-13 14:31:35 +00:00
|
|
|
|
|
|
|
// Scan via trivy
|
2022-01-13 13:30:51 +00:00
|
|
|
stage('Scan'){
|
|
|
|
environment {
|
2022-01-13 14:31:35 +00:00
|
|
|
TRIVY_TEMPLATE = "@${env.HOME}/html.tpl"
|
2022-01-13 13:30:51 +00:00
|
|
|
TRIVY_FORMAT = "template"
|
|
|
|
TRIVY_OUTPUT = "reports/trivy.html"
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
sh 'mkdir -p reports'
|
|
|
|
sh 'make scan'
|
|
|
|
publishHTML target : [
|
|
|
|
allowMissing: true,
|
|
|
|
alwaysLinkToLastBuild: true,
|
|
|
|
keepAll: true,
|
|
|
|
reportDir: 'reports',
|
|
|
|
reportFiles: 'trivy.html',
|
2022-01-13 14:17:18 +00:00
|
|
|
reportName: 'TrivyScan',
|
|
|
|
reportTitles: 'TrivyScan'
|
2022-01-13 13:30:51 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
// Scan again and fail on CRITICAL vulns
|
|
|
|
sh 'TRIVY_EXIT_CODE=1 TRIVY_SEVERITY=CRITICAL make scan'
|
|
|
|
}
|
|
|
|
}
|
2022-01-13 14:31:35 +00:00
|
|
|
|
|
|
|
// Push to ECR
|
2022-01-13 13:30:51 +00:00
|
|
|
stage('Push'){
|
|
|
|
steps {
|
2022-01-13 14:31:35 +00:00
|
|
|
sh 'make push'
|
2022-01-13 13:30:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|