Skip to content

[CI] Publish JUnit/Surefire test results in Jenkins pipelines for dashboard visualization #3835

@manusa

Description

@manusa

Description

The Jenkins pipelines defined in .jenkins/pipelines/ currently run tests but do not publish the JUnit/Surefire test results. This means the Jenkins dashboard cannot display a proper visualization of test results, including:

  • Test trend graphs over time
  • Failing test breakdowns with stack traces
  • Test duration analysis
  • Test stability metrics

Publishing these results would significantly improve the developer experience when investigating build failures and tracking test health.

Background

The following pipelines run Maven builds with tests:

Pipeline Runs Tests Publishes Results
java-8.Jenkinsfile ./mvnw install ❌ No
sonar.Jenkinsfile ./mvnw -Pjacoco,sonar install ❌ No
release-snapshots.Jenkinsfile -DskipTests implied via deploy N/A

Expected Behavior

After a build completes (success or failure), the Jenkins dashboard should:

  1. Display the total number of tests run, passed, failed, and skipped
  2. Show a test trend graph across builds
  3. Allow drilling down into individual failing tests with stack traces
  4. Preserve test history for regression analysis

Proposed Solution

Add a post block to the relevant Jenkinsfiles to archive and publish test results using the junit step:

post {
  always {
    junit testResults: '**/target/surefire-reports/*.xml', allowEmptyResults: true
  }
}

For the pipelines that may also run Failsafe integration tests, consider:

post {
  always {
    junit testResults: '**/target/surefire-reports/*.xml,**/target/failsafe-reports/*.xml', allowEmptyResults: true
  }
}

Affected Pipelines

  • .jenkins/pipelines/java-8.Jenkinsfile
  • .jenkins/pipelines/sonar.Jenkinsfile

Additional Information

Acceptance Criteria

  • Test results are published after each build in java-8.Jenkinsfile
  • Test results are published after each build in sonar.Jenkinsfile
  • Jenkins dashboard shows test trends for affected pipelines
  • Failing tests are visible with stack traces in the Jenkins UI
  • Test results are preserved even when the build fails

Tests

  • Trigger a build with a failing test and verify the failure is visible in Jenkins UI
  • Verify test trend graphs appear after multiple builds
  • Confirm stack traces are accessible for failed tests

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions