Parent pipeline and its child pipeline have different behaviours with different environments

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

A child pipeline does not allow for the same interactions/actions as its parent, as described in #215725 (comment 490741023) by @TheDeeM

Steps to reproduce

Two examples illustrate this discrepancy:

  1. No deploy button available in child pipeline

As you can see, here is a merge request, which has two environments ready to be deployed (one in the main pipeline, the second one in the trigger/child pipeline). > The first one is available as a Deploy button, the second one is not.

no-deploy

  1. Not all pipelines are stopped when MR is closed

And here I have prepared a MR where I deployed both previous environments, then closed the MR. Only the main environment was auto-triggered to be stopped:

auto-stop

And within the child pipeline the stop was not executed: ![auto-stop-executed](https://gitlab.com/gitlab-> org/gitlab/uploads/a643de6a7efa69b58361b19f24ccef97/image.png)

Example Project

.gitlab-ci.yml that triggered the first no deploy button example

---
stages:
  - review
  - deploy

review-environment:
  stage: review
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      when: on_success
  variables:
    ENVIRONMENT_NAME: environments/${CI_BUILD_REF_NAME}
  trigger:
    include: environment-pipeline.yml

start-environment:
  stage: deploy
  environment:
    name: ${ENVIRONMENT_NAME}-main-pipeline
    url: https://${CI_COMMIT_REF_SLUG}-main-pipeline.my-environment.com
    on_stop: stop-environment
    auto_stop_in: 3 days
  script:
    - echo "Environment deployed"
  rules:
    - when: manual

stop-environment:
  stage: deploy
  rules:
    - when: manual
      allow_failure: true
  environment:
    name: ${ENVIRONMENT_NAME}-main-pipeline
    action: stop
  script:
    - echo "Environment stopped"

.gitlab-ci.yml that triggered the no auto stop on close example:

---
stages:
  - review
  - deploy

review-environment:
  stage: review
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
      when: on_success
  variables:
    ENVIRONMENT_NAME: environments/${CI_BUILD_REF_NAME}
  trigger:
    include: environment-pipeline.yml

start-environment:
  stage: deploy
  environment:
    name: ${ENVIRONMENT_NAME}-main-pipeline
    url: https://${CI_COMMIT_REF_SLUG}-main-pipeline.my-environment.com
    on_stop: stop-environment
    auto_stop_in: 3 days
  script:
    - echo "Environment deployed"
  rules:
    - when: manual

stop-environment:
  stage: deploy
  rules:
    - when: manual
      allow_failure: true
  environment:
    name: ${ENVIRONMENT_NAME}-main-pipeline
    action: stop
  script:
    - echo "Environment stopped"

What is the current bug behavior?

As described above.

What is the expected correct behavior?

Consistency between parent and its child pipeline. e.g. Same deploy button should be available and all pipeline should be stopped upon closing MR.

Edited by 🤖 GitLab Bot 🤖