Skip to content

Adds a mergeTrainIndex field to merge requests

Miguel Rincon requested to merge 429263-add-merge_train_index-field-to-mr into master

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

MR chain
Adds a mergeTrainIndex field to merge requests (!153954 - merged) you are here!
Update merge train position using GraphQL (!153973 - merged)
Show toast message when merge request is remove... (!153974 - merged)

Query example

query getState($projectPath: ID!, $iid: String!) {
  project(fullPath: $projectPath) {
    id
    mergeRequest(iid: $iid) {
      id
      title
      mergeTrainsCount
      mergeTrainIndex # New!
    }
  }
}

MR acceptance checklist

image

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

Merge request reports