Adds a mergeTrainIndex field to merge requests
What does this MR do and why?
Adds a mergeTrainIndex
field to merge requests.
This change adds a new field to the merge request type that reveals the position of the merge request in a merge train, when available.
Relates to #442453 (closed).
Changelog: added
Query example
query getState($projectPath: ID!, $iid: String!) {
project(fullPath: $projectPath) {
id
mergeRequest(iid: $iid) {
id
title
mergeTrainsCount
mergeTrainIndex # New!
}
}
}
MR acceptance checklist
How to set up and validate locally
I set up a simple project with a pipeline that fails only on merge trains:
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
I also enabled Merge trains for the project at Settings -> Merge requests (e.g. http://gdk.test:3000/my-group/merge-trains/-/settings/merge_requests.
When I open any MR, I can fetch information on it, using the query above to fetch the current information.
Related to #429263 (closed)
Edited by Veethika Mishra