Jenkinsfile · Lesson 7 of 10 · 3 min read
Reports, artifacts and notifications
junit testResults: '**/surefire-reports/*.xml', allowEmptyResults: false // failing tests → UNSTABLE
jacoco execPattern: '**/jacoco.exec' // coverage (plugin)
recordIssues tools: [checkStyle(), spotBugs()] // Warnings NG
archiveArtifacts artifacts: 'build/libs/*.jar', fingerprint: true, onlyIfSuccessful: true
publishHTML target: [reportDir: 'reports/e2e', reportFiles: 'index.html', reportName: 'E2E']
Quality gates — fail fast on quality and security:
stage('SonarQube') {
steps {
withSonarQubeEnv('sonar') { sh 'mvn -B sonar:sonar' }
timeout(time: 10, unit: 'MINUTES') { waitForQualityGate abortPipeline: true }
}
}
stage('Image scan') {
steps { sh 'trivy image --exit-code 1 --severity CRITICAL,HIGH --ignore-unfixed $IMAGE:$GIT_COMMIT' }
}
Because the scan stage fails the build, later deploy stages never run with critical vulnerabilities — the gate is enforced by pipeline order.
Enlarge diagram
Swipe sideways to see all of it, or tap to open it full screen.
Notifications go in post: Slack/Teams/email on failure, fixed and regression — not on every success (noise).
Build metadata helps humans:
script {
currentBuild.displayName = "#${env.BUILD_NUMBER} · ${env.GIT_COMMIT.take(7)}"
currentBuild.description = "image ${env.IMAGE}:${env.GIT_COMMIT.take(7)}"
}