Testing and Reporting
Continuous Integration is not just about building code – it’s about ensuring quality. Jenkins can run tests and publish various reports (JUnit, HTML, coverage) to help you catch issues early.
Publishing JUnit Test Results
Most testing frameworks (JUnit, pytest, Maven Surefire) output XML files. Use the
junit step in the post section.post {
always {
junit '**/target/surefire-reports/*.xml'
}
}Jenkins then displays test results with trend graphs and failure details.Publishing HTML Reports
If your tests generate HTML reports (e.g., coverage reports), install the "HTML Publisher" plugin. Then:
publishHTML([
reportDir: 'build/reports',
reportFiles: 'index.html',
reportName: 'Coverage Report'
])Archiving Artifacts
Save binary artifacts (JARs, binaries) for later use or deployment.
archiveArtifacts artifacts: 'target/*.jar', fingerprint: trueSetting Build Result Based on Test Outcome
If tests fail, the build will be marked as "unstable" (not failed). To force a failure, you can check test results and set
currentBuild.result.Using the Pipeline Syntax Generator
Jenkins provides a "Pipeline Syntax" link in any pipeline job. Use it to generate the correct code for steps like
junit, archiveArtifacts, and publishHTML.Two Minute Drill
- Publish JUnit XML reports with
junitstep. - Install HTML Publisher plugin for custom HTML reports.
- Archive artifacts with
archiveArtifacts. - Use post‑build actions or post section to publish reports.
Need more clarification?
Drop us an email at career@quipoinfotech.com
