Skip to content

Allow retry of merge train pipeline while its running

Miguel Rincon requested to merge 4643390-jobs-retryable-state into master

What does this MR do and why?

Fixes Present an option to retry jobs in a merge trai... (#464339)

Merge trains are not retryable when the pipeline fails, because as soon as the pipeline fails, the train is invalidated from that point onwards.

If the pipeline is still running, then retrying the job can enable users to keep the pipeline in the train.

Changelog: changed

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

While running (can be retried) After failure (cannot be retried)
Screenshot_2024-05-31_at_15.45.06 image

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 running pipeline, that gets removed when the pipeline fails.

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

Edited by Miguel Rincon

Merge request reports