Skip to content

Only show "Merge request was removed from train" for open MRs

What does this MR do and why?

This change restricts the toast notification so it's only shown when the MR is still open. This prevents showing the notification when it is not necessary.

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

MR failing train pipeline
2024-06-07_11.12.54
MR passing train pipeline and getting merged
2024-06-07_11.13.40

How to set up and validate locally

  1. Set up a project with Merge trains enabled.
You can use this .gitlab-ci.yml
workflow:
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'

stages:
  - build

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

merge-train-job:
  stage: build
  rules:
    - if: $CI_MERGE_REQUEST_EVENT_TYPE == 'merge_train'
  script:
    - echo $CI_MERGE_REQUEST_EVENT_TYPE
    - sleep 1
    - echo "Done!"
  1. Open an MR which makes the train pipeline fail:

image

You can use this .gitlab-ci.yml
workflow:
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'

stages:
  - build

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

merge-train-job:
  stage: build
  rules:
    - if: $CI_MERGE_REQUEST_EVENT_TYPE == 'merge_train'
  script:
    - echo $CI_MERGE_REQUEST_EVENT_TYPE
    - echo "Failing now, sorry!"
    - exit 1
  1. Update the MR so it passes, by removing the new lines and adding it to the merge train.

Related to #465903 (closed)

Edited by Miguel Rincon

Merge request reports