Uploaded image for project: 'OpenShift Pipelines'
  1. OpenShift Pipelines
  2. SRVKP-7858

Make PipelineRun status exposed on the Git provider configurable via templates

XMLWordPrintable

    • False
    • Hide

      None

      Show
      None
    • False

      Story (Required)

      As a Cluster Operator, trying to customize the status report of a
      PipelineRun, I want to define a custom Go template for the GitHub CheckRun
      summary screen.

      This will allow operators to have full control over the information displayed
      in the CheckRun summary on GitHub. Instead of a fixed table, they can create a
      tailored view that highlights the most important results, statuses, or logs
      relevant to their specific workflows, thus improving the observability and user
      experience for developers.

      Background (Required)

      Currently, the status summary displayed on the GitHub CheckRun screen is
      hardcoded in the `pipelines-as-code` controller. The format is defined by the
      `taskStatusTemplate` constant located
      here.

      There is a need to make this output configurable so that operators can decide
      what information is presented. For example, they may want to display specific
      `PipelineRun` results, change the layout, or add links to other systems. This
      story proposes allowing a global, cluster-wide configuration for this template.

      Out of scope

      • Per-repository or per-`Repository` CRD configuration for the template. This
        initial implementation will be global.
      • Advanced templating logic that cannot be achieved with standard Go templates
        (e.g., complex conditional coloring like the "ADR status colors"). The user
        will be limited by the capabilities of Go's `text/template` package.

      Approach (Required)

      The proposed approach is to introduce a new field in the `pipelines-as-code`
      global configuration (e.g., in the ConfigMap) where a cluster operator can
      specify a custom Go template string for the CheckRun summary.

      • The entire `PipelineRun` object will be available as context to the template,
        allowing access to its status, results, and other details.
      • The system will expose a few built-in helper functions to the template, such
        as `formatDuration` and `formatCondition`.
      • If the configuration field for the custom template is empty or not present,
        the system will fall back to the default, existing template to ensure backward
        compatibility.
      • The default template is:
      const taskStatusTemplate = `
      <table>
        <tr><th>Status</th><th>Duration</th><th>Name</th></tr>
      
      {{- range $taskrun := .TaskRunList }}
      <tr>
      <td>{{ formatCondition $taskrun.PipelineRunTaskRunStatus.Status.Conditions }}</td>
      <td>{{ formatDuration $taskrun.PipelineRunTaskRunStatus.Status.StartTime $taskrun.PipelineRunTaskRunStatus.Status.CompletionTime }}</td><td>
      
      {{ $taskrun.ConsoleLogURL }}
      
      </td></tr>
      {{- end }}
      </table>`
      

      Provider Limitations

      The generated output from the template is subject to the limitations of the
      underlying Git provider's API.

      For example when using GitHub and GitHub Checks these are:

      • Content: The summary field is limited GitHub Flavored Markdown.
      • Size: The summary field has a maximum size of 65,535 characters.
        The rendered output of the user's template must not exceed this limit.

      This will be the responsibility of the cluster administrator to ensure that the
      template they provide does not exceed these limits.

      Dependencies

      None identified at this time.

      Acceptance Criteria (Mandatory)

      • A Cluster Operator can configure a custom Go template string in the global `pipelines-as-code` settings.
      • When a custom template is provided, the GitHub CheckRun summary is rendered using that template.
      • When no custom template is provided, the CheckRun summary is rendered using the default, hardcoded template.
      • The template execution context has access to the full `PipelineRun` object and its associated data.
      • The template has access to helper functions like `formatDuration` and `formatCondition`.
      • If a user provides a malformed or invalid Go template, the system handles it gracefully by logging an error and falling back to the default template.
      • If the rendered template output exceeds the provider's character limit (e.g., 65,535 for GitHub), the system should handle it gracefully (e.g., by truncating the output and adding a warning, or falling back to the default).
      • User-facing documentation is updated to explain how to use the custom
        template feature and explicitly mention the provider-specific limitations
        (character limits, supported Markdown, etc.).

              Unassigned Unassigned
              cboudjna@redhat.com Chmouel Boudjnah
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: