Skip to content

Allow individual jobs to be retried in running merge trains

Miguel Rincon requested to merge 464339-retryable-individual-job into master

What does this MR do and why?

This change allows jobs to be retries in merge trains as long as the pipeline hasn't completed.

When the pipeline is completed, retrying is disabled as this has no effect.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

During execution of the pipleline, users are able to re-run jobs via different retry buttons, these are consistent in our different views:

Running pipeline Failed pipeline
running failed
running-big-pipeline failed-big-pipeline
running-failed-jobs failed-failed-jobs

How to set up and validate locally

  1. I used the following pipeline, when one jobs fails we can still attempt to retry it (in the pipelines tab).
workflow:
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'

stages:
  - build

normal-job:
  stage: build
  environment: production
  script:
    - echo "Running..."
    - sleep 30
    - echo "Done."

fail-on-merge-train:
  stage: build
  rules:
    - if: $CI_MERGE_REQUEST_EVENT_TYPE == 'merge_train'
  script:
    - echo $CI_MERGE_REQUEST_EVENT_TYPE
    - sleep 30
    - echo "Failing becuase this is a merge train, sorry!"
    - exit 1

fail-on-merge-train-later:
  stage: build
  rules:
    - if: $CI_MERGE_REQUEST_EVENT_TYPE == 'merge_train'
  script:
    - echo $CI_MERGE_REQUEST_EVENT_TYPE
    - sleep 50
    - echo "Failing becuase this is a merge train, sorry!"
    - exit 1
  1. Enable merge trains by selecting "Enable merge trains" at Project -> Settings -> Merge requests (e.g. http://gdk.test:3000/my-group/my-merge-trains/-/settings/merge_requests)
  2. Open an MR with an arbitrary change
  3. Hit Merge and wait for the merge train pipeline to fail
  4. Visit the Pipelines tab and confirm there is a retry button for the jobs as they fail.

Before the merge train pipeline is finished I can restart the failed job, to keep the pipeline from failing.

Related to #464339

Edited by Miguel Rincon

Merge request reports