Skip to content

Add retry job action to trigger job page

Mireya Andres requested to merge retry-trigger-job into master

What does this MR do and why?

For #350243 (closed)

A trigger job (or bridge job) is a job whose purpose is to trigger/create a downstream pipeline. When the user goes to the show page for a trigger job and clicks on the Retry button, this will re-create a new downstream pipeline and trigger job, replacing the current one.

Note that the default behavior for trigger jobs is that the status will become success when the downstream pipeline is created. The status of the trigger job is not synced or dependent on the status of the downstream pipeline.

No changelog added since this feature is behind a feature flag.

Note that there are follow ups to this that will not be covered in this MR:

MR Breakdown

This is dependent on !79636 (closed), the backend counterpart for this MR.

It might be easier to review this MR by going through the commits to see how the feature is put together.

Commit Description
!78444 (033554f9) Emit retryBridgeJob event from retry button in the sidebar
!78444 (eb159475) Add retry bridge mutation
!78444 (da1462b1) Poll for pipeline updates after retrying the bridge job (uses etag caching)
!78444 (81c4668d) Show error alert if the mutation fails
!78444 (64c51a1e) Handle behavior when mutation is successful

Screenshots or screen recordings

Retrying a Trigger Job With Error
success error

Retrying a trigger job will result in the following changes on the UI:

  • A loading state will be displayed.
  • While the mutation is not yet done, the retry button will be disabled.
  • Trigger job status may show up as pending while the downstream pipeline is not yet created. It doesn't take long for a trigger job to finish though, so depending on the timing of the polling, it's possible the pending state doesn't show up before the page is redirected.
  • Once the downstream pipeline is created, the page will redirect to the newly-created downstream pipeline.

How to set up and validate locally

  1. Pull the backend changes from !79636 (closed)
  2. Pull the frontend changes from this MR.
  3. Enable the ci_retry_downstream_pipeline feature flag. (rails c then Feature.enable(:ci_retry_downstream_pipeline))
  4. Add the following content to your .gitlab-ci.yml file:
    stages:
      - build
    
    triggerJob:
      stage: build
      trigger:
        include:
          - project: "/path/to/project" # replace with another project
            file: ".gitlab-ci.yml"
  5. Wait for the pipeline to finish running.
  6. Visit the pipeline and click on the triggerJob job pill. This should take you to the job page for triggerJob.
  7. Click on the Retry button in the sidebar.
  8. A new bridge job and downstream pipeline will be created, which you can now visit through the link in the middle of the page.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Mireya Andres

Merge request reports