sns-alert-hub/vars/buildPodman.groovy
Stefan Reimer 8979d74665 Squashed '.ci/' changes from 56c6ad9..98c8ec1
98c8ec1 Feat: Execute tests via docker run rather than at the end of the test build process
d6b2fb4 feat: improve messaging if Trivy fail is skipped
b6fea5a fix: fix quotes, do not execute scan during push
db97da8 feat: revert extraSteps for now
322285e feat: add ability to execute custom extraSteps
ba21a45 feat: make trivy scan cause build to fail configurable
ba73be4 feat: make Dockerfile.test optional, improve messaging
b9aa3de chore: groovy formating
f0f4af2 chore: learning the groove
a3d42de chore: typing is hard

git-subtree-dir: .ci
git-subtree-split: 98c8ec138a895b02cadf029871b7466b4699f2a3
2022-02-24 11:54:30 +01:00

72 lines
1.7 KiB
Groovy

// Common container builder by ZeroDownTime
def call(Map config=[:]) {
pipeline {
agent {
node {
label 'podman-aws-trivy'
}
}
stages {
stage('Prepare') {
// get tags
steps {
sh 'git fetch -q --tags ${GIT_URL} +refs/heads/${BRANCH_NAME}:refs/remotes/origin/${BRANCH_NAME}'
}
}
// Build using rootless podman
stage('Build') {
steps {
sh 'make build'
}
}
stage('Test') {
steps {
sh 'make test'
}
}
// Scan via trivy
stage('Scan') {
environment {
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',
reportName: 'TrivyScan',
reportTitles: 'TrivyScan'
]
// Scan again and fail on CRITICAL vulns, if not overridden
script {
if (config.trivyFail == 'NONE') {
echo 'trivyFail == NONE, review Trivy report manually. Proceeding ...'
} else {
sh "TRIVY_EXIT_CODE=1 TRIVY_SEVERITY=${config.trivyFail} make scan"
}
}
}
}
// Push to ECR
stage('Push') {
steps {
sh 'make push'
}
}
}
}
}