Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-76148

Report Tab is missing from the Job/Project page when keepAll:false while running pipeline Job (not Freestyle)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • htmlpublisher-plugin
    • None
    • - Jenkins version: 2.479+
      - HTML Publisher Plugin version: 1.32+
      - Affects: Pipeline jobs (WorkflowJob) only
      - Does not affect: Freestyle jobs (different action factory)

        1. HTML Publisher Plugin: Report tabs disappear when keepAll=false and Pipeline builds fail*
           
          1. Problem Description*
             
            When using the HTML Publisher plugin with Pipeline jobs (WorkflowJob), report tabs disappear from the project page under the following specific conditions:
             
            -`keepAll` is set to `false`
      • The most recent build has failed (FAILURE, UNSTABLE, etc.)
      • There is no successful build available
         
          1. Expected Behavior*
             
            Report tabs should be visible on the project page regardless of build status when HTML reports have been published, matching the behavior when `keepAll=true`.
             
          2. Actual Behavior*
             
            Report tabs are **not visible** on the project page when `keepAll=false` and the latest build has failed, even though the HTML reports were successfully published during that failed build.
             
          3. Root Cause Analysis*
             
            The issue is in `WorkflowActionsFactory.java` which is responsible for creating project-level actions (tabs) for Pipeline jobs. The original implementation had a critical flaw:
             
            **Original problematic code:**
            ```java
            final Run<?,?> r = j.getLastSuccessfulBuild();
            if (r != null) { // Process both HTMLBuildAction and HTMLPublishedForProjectMarkerAction from same build List<HtmlPublisherTarget.HTMLBuildAction> reports = r.getActions(HtmlPublisherTarget.HTMLBuildAction.class); // ... process reports List<HtmlPublisherTarget.HTMLPublishedForProjectMarkerAction> projectLevelReports = r.getActions(HtmlPublisherTarget.HTMLPublishedForProjectMarkerAction.class); // ... process project reports }

            ```
             
            **The problem:** The factory only checked `getLastSuccessfulBuild()` and completely ignored `getLastBuild()`. When builds fail:

      • `getLastSuccessfulBuild()` returns `null` (no successful builds available)
      • The entire action creation logic is skipped
      • No project tabs are created, even though failed builds may contain `HTMLPublishedForProjectMarkerAction` (for `keepAll=false` reports)
         
          1. Impact*
             
            This affects Pipeline jobs using HTML Publisher with:
      • `keepAll=false` configuration
      • Builds that fail but still generate HTML reports
      • Projects where the most recent successful build is older or non-existent
         
        The reports are still accessible via direct URLs but the UI tabs disappear, creating poor user experience.
         
          1. Reproduction Steps*
             
            1. Create a Pipeline job with HTML Publisher step using `keepAll: false`
            2. Configure the pipeline to publish HTML reports but then fail (e.g., with `error()` step)
            3. Run the job until it fails
            4. Observe that report tabs are missing from the project page
            5. Verify reports are still accessible via direct URLs
             
          2. Environment*
             
      • Jenkins version: 2.479+
      • HTML Publisher Plugin version: 1.32+
      • Affects: Pipeline jobs (WorkflowJob) only
      • Does not affect: Freestyle jobs (different action factory)
         
          1. Related Code*
             
      • {}Primary fix{}: `src/main/java/htmlpublisher/workflow/WorkflowActionsFactory.java`
      • {}Supporting fix{}: `src/main/java/htmlpublisher/HtmlPublisherTarget.java` (UI action methods)
         
          1. Test Coverage*
             
            Comprehensive test suite added in `WorkflowActionsFactoryTest.java` covering:
      • Failed builds with `keepAll=false` (core issue)
      • Successful builds with `keepAll=true` (regression prevention)
      • Mixed scenarios with both successful and failed builds
      • Edge cases (no builds, null builds, non-workflow jobs)

            aviral282 Aviral
            aviral282 Aviral
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: