Auto stop environments for triggered pipelines in merge requests

Hi there,
can somebody please help me out in the following github issue?
I’m trying to create a ci pipeline on where the main job will trigger another pipeline from a file which will create an environment (example repo with test pipelines: Attila Csoma / env-test · GitLab).
My goal is to use the triggered job to create an environment and delete it when I delete the branch which triggered the pipeline (last line in this paragraph: Environments and deployments | GitLab).

Now my pipeline looks like this:

    - test
  stage: test
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      - local: pipeline.yaml
    strategy: depend


   - when: always
  stage: deploy
  image: busybox:1.33.1-glibc
    - echo "Deploy a review app"
    name: review/$CI_COMMIT_REF_NAME
    url: https://$
    on_stop: stop_review
  stage: deploy
  image: busybox:1.33.1-glibc
    - echo "Remove review app"
    name: review/$CI_COMMIT_REF_NAME
    action: stop
    - when: manual
      allow_failure: true

The issue is that if I use ‘push’ in gitlab-ci.yml in test_pipeline.rules.[].if ( - if: '$CI_PIPELINE_SOURCE == "push"' ) everything works fine. After a push event it will trigger
the pipeline, which will create the environment and if I delete the branch it will trigger the stop_review job.
However, if I try to limit it to start the pipeline only for merge requests (so use the merge_request_event as CI_PIPELINE_SOURCE) then if I open merge request it will start the ci which will create the environment but if I merge the merge request with delete source branch option enabled it will not trigger the stop_review event (the branch will be deleted however).
I didn’t found any reference in the documentation that it should not work (the env auto stop feature) for merge requests too. Maybe I’m missing something. I tried the gitlab api to look for any differences between a working and non working environment/deployment json structure but didn’t found anything.

Any help would be appreciated :slight_smile:
Thanks in advance


could you solve this?

We have the same issue that we are able to launch multiple environments via a matrix job, but those environments wont auto stop (manual stop does work fine). They also seem to be correctly assigned as they shop up in the merge request an can be clicked.