Allow retry of merge train pipeline while its running
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) |
---|---|
How to set up and validate locally
- 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
- 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)
- Open an MR with an arbitrary change
- Hit Merge and wait for the merge train pipeline to fail
- 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