Skip to content

feat(freestyle): Allow multiple report configurations in Freestyle pr… #461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

totocaca123
Copy link
Collaborator

…ojects

This change addresses the limitation where Freestyle projects could only have a single "Publish report files" post-build action.

Modifications:

  • ReportRecorder.java:
    • Introduced an inner class ReportConfig to encapsulate name, provider, and displayType for a single report.
    • ReportRecorder now holds a List<ReportConfig> to manage multiple report configurations.
    • The perform method iterates through these configurations, processing each report (scanning and publishing).
    • readResolve is implemented for backward compatibility, migrating old single-report job configurations to the new list format.
  • config.jelly (for ReportRecorder):
    • Updated to use <f:repeatableProperty field="reportConfigs">, enabling you to add and configure multiple reports in the job UI.
  • Unit Tests:
    • Added testReadResolve_migratesOldConfiguration to ensure smooth migration of existing job configurations.
    • Added testPerform_processesAllReportConfigs to verify that multiple configured reports are processed correctly by the perform method.

This allows you to define multiple instances of report file configurations (JSON, XML, CSV, YAML) in your Freestyle projects, similar to what is possible in Pipeline projects.

Testing done

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

…ojects

This change addresses the limitation where Freestyle projects could only have a single "Publish report files" post-build action.

Modifications:
- ReportRecorder.java:
  - Introduced an inner class `ReportConfig` to encapsulate `name`, `provider`, and `displayType` for a single report.
  - ReportRecorder now holds a `List<ReportConfig>` to manage multiple report configurations.
  - The `perform` method iterates through these configurations, processing each report (scanning and publishing).
  - `readResolve` is implemented for backward compatibility, migrating old single-report job configurations to the new list format.
- config.jelly (for ReportRecorder):
  - Updated to use `<f:repeatableProperty field="reportConfigs">`, enabling you to add and configure multiple reports in the job UI.
- Unit Tests:
  - Added `testReadResolve_migratesOldConfiguration` to ensure smooth migration of existing job configurations.
  - Added `testPerform_processesAllReportConfigs` to verify that multiple configured reports are processed correctly by the `perform` method.

This allows you to define multiple instances of report file configurations (JSON, XML, CSV, YAML) in your Freestyle projects, similar to what is possible in Pipeline projects.
This commit addresses compilation errors that arose after refactoring ReportRecorder to support multiple report configurations.

Fixes:
- ReportRecorder.java:
  - Reintroduced deprecated @DataBoundSetter methods for `setName`, `setProvider`, and `setDisplayType`. These methods adapt single-report configurations to the new list-based `reportConfigs` structure by operating on the first element of the list. This ensures backward compatibility for pipeline steps using ReportRecorder.
  - Corrected the instantiation of `ReportResult` in the `perform` method. The `finalResult` variable is now initialized with `new ReportResult(run, new Report())` to provide a valid, empty result if no reports are processed, resolving a constructor argument mismatch.

These changes allow the project to compile successfully while retaining the functionality for multiple report configurations in Freestyle projects and ensuring continued operation for pipeline steps.
… resolve the test compilation errors you were seeing due to the missing `org.mockito` package.
This commit addresses test compilation failures by:
1. Changing the visibility of the `scan` method in `ReportRecorder.java`
   from private to package-private. This allows Mockito to spy on the
   method from test classes in the same package.
2. Correcting the usage of `DisplayType` in `ReportRecorderTest.java`.
   The test was attempting to use a non-existent `DisplayType.PIE`
   constant. This has been changed to use `DisplayType.RELATIVE`
   (with the corresponding string "relative" in setup), which is a
   valid enum constant.
Updates mockito-core dependency from 4.11.0 to 5.12.0.
This is an attempt to resolve JVM crashes during test execution on JDK 21,
as newer Mockito versions generally offer better compatibility with recent JDKs.
Replaces mockito-core with mockito-inline (version 5.12.0).
This change aims to resolve JVM crashes during Surefire test execution
by using Mockito's inline mock maker, which can be more robust on
modern JDKs and with complex classloader/module setups.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants