Publishing JUnit Test Reports in Jenkins Pipeline
📖 Scenario: Your team runs Java unit tests using Maven. The tests generate JUnit XML reports, but developers have to SSH into the build server to check results. You want to configure the Jenkins pipeline to automatically publish test reports so the team can view results directly in the Jenkins UI.
🎯 Goal: Build a Jenkins pipeline that runs Maven tests and publishes JUnit XML reports using the junit step, with proper error handling so reports are published even when tests fail.
📋 What You'll Learn
Create a Jenkins pipeline with a
pipeline block and agent anyAdd a
Test stage that runs mvn testAdd a
post section with always to publish JUnit reportsUse the
junit step with the correct report path patternPrint a confirmation message after report publishing
💡 Why This Matters
🌍 Real World
Publishing JUnit reports in Jenkins gives teams instant visibility into test health without SSH access, enabling faster feedback loops.
💼 Career
DevOps engineers configure test report publishing as a standard part of CI/CD pipelines for every Java project.
Progress0 / 4 steps