Skip to content

Jenkins - Reporting

Beyond simple pass/fail status, Jenkins can publish various reports generated during the build process, providing deeper insights into quality, coverage, and analysis.

This typically involves configuring your build or test tools to generate report files in a format Jenkins understands (or can be made to understand via plugins), and then using specific Pipeline steps or post-build actions to publish them.

Common Report Types and How to Publish Them

Section titled “Common Report Types and How to Publish Them”
  • Purpose: Show detailed unit/integration/E2E test results, trends, failures, and stack traces.
  • Generation: Configure your test framework (JUnit, TestNG, pytest, Jest, NUnit, etc.) and build tool (Maven Surefire/Failsafe, Gradle Test, dotnet test, npm test) to output reports in JUnit XML format.
  • Jenkins Step: Use the junit step (from the built-in JUnit plugin).
  • Example (Pipeline post block): junit '**/target/surefire-reports/*.xml' or junit '**/build/test-results/test/*.xml'

2. Code Coverage Reports (JaCoCo, Cobertura, etc.)

Section titled “2. Code Coverage Reports (JaCoCo, Cobertura, etc.)”
  • Purpose: Visualize line, branch, and method coverage achieved by tests.
  • Generation: Instrument code and run tests using coverage tools integrated with your build (e.g., JaCoCo Maven/Gradle plugin, Istanbul/nyc for JavaScript, Coverage.py for Python). These tools generate XML or HTML reports.
  • Jenkins Plugin: Install the ‘Code Coverage API Plugin’ plus a specific plugin for your format (e.g., ‘JaCoCo’, ‘Cobertura Coverage’).
  • Jenkins Step: Use the step provided by the specific plugin (e.g., jacoco() or publishCoverage adapters: [cobertura('**/target/site/cobertura/coverage.xml')]).
  • Example (Pipeline post block with JaCoCo): jacoco execPattern: '**/target/jacoco.exec', classPattern: '**/target/classes', sourcePattern: '**/src/main/java'

3. Static Analysis Reports (Checkstyle, PMD, SpotBugs, ESLint)

Section titled “3. Static Analysis Reports (Checkstyle, PMD, SpotBugs, ESLint)”
  • Purpose: Display violations of coding standards, potential bugs, and bad practices detected by static analysis tools.
  • Generation: Run analysis tools as part of your build (e.g., Checkstyle/PMD/SpotBugs Maven/Gradle plugins, ESLint via npm scripts). Configure them to generate XML or JSON report files.
  • Jenkins Plugin: Install the ‘Warnings Next Generation’ plugin. This is the modern standard, replacing older individual analysis plugins.
  • Jenkins Step: Use the recordIssues step, configuring the specific tool and report file pattern.
  • Example (Pipeline post block): recordIssues tools: [checkStyle(pattern: '**/target/checkstyle-result.xml'), pmdParser(pattern: '**/target/pmd.xml'), spotbugs(pattern: '**/target/spotbugsXml.xml')]
  • Purpose: Display any custom report generated in HTML format (e.g., test reports from frameworks like Cypress or Allure, documentation, analysis dashboards).
  • Generation: The tool or script generating the report should produce an index.html file and associated assets (CSS, JS, images) in a specific directory.
  • Jenkins Plugin: Install the ‘HTML Publisher’ plugin.
  • Jenkins Step: Use the publishHTML step, specifying the directory containing the HTML report and the main file.
  • Example (Pipeline post block): publishHTML(target: [allowMissing: true, alwaysLinkToLastBuild: true, keepAll: false, reportDir: 'target/my-custom-report', reportFiles: 'report.html', reportName: 'My Custom Report'])

Once published, links to these reports will appear on the build’s main page sidebar. Clicking these links will display the report integrated within the Jenkins UI (for JUnit, Coverage, Warnings NG) or navigate to the published HTML content.

These reports provide valuable feedback loops, helping developers quickly identify issues related to tests, code quality, and coverage directly from Jenkins.