Merging triggers manual environment on_stop action
Summary
Certain projects configured with a action: prepare
job for their environments cause other jobs that stop that same environment to be automatically triggered even when they are configured for when: manual
.
Steps to reproduce
- add this YML to repo in dev branch Create a project with a
.gitlab-ci.yml
file similar to the one below. - Create a new
dev
branch. - Run a new pipeline and trigger the
Plan DEV
andApply DEV
jobs, which deploys an environment. - Create a new merge request into the
dev
branch. - Merge the MR.
- Observe that the manual
Stop DEV
job is run automatically. - Optionally, comment out the
action: prepare
line of thePlan DEV
job and run a new pipeline. - Observe that the
Stop DEV
job is not run automatically.
stages:
- plan
- apply
image:
name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/alpine
Plan DEV:
# Comment out environment and needs and the pipeline will NOT trigger a STOP on a previously deployed environment when you merge into dev branch
environment:
name: dev
action: prepare
needs: []
stage: plan
script:
- echo "PLAN DEV! ${CI_COMMIT_BRANCH}"
rules:
- if: '$CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "main" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"'
when: never
- when: on_success
Apply DEV:
stage: apply
script:
- echo "APPLY DEV! ${CI_COMMIT_BRANCH}"
environment:
name: dev
on_stop: Stop DEV
dependencies:
- Plan DEV
rules:
- if: $CI_COMMIT_BRANCH
when: manual
Stop DEV:
stage: apply
script:
- echo "STOP DEV! ${CI_COMMIT_BRANCH}"
environment:
name: dev
action: stop
rules:
- if: $CI_COMMIT_BRANCH
when: manual
What is the current bug behavior?
Jobs that stop an environment are automatically run in the presence of the action: prepare
keyword.
What is the expected correct behavior?
Jobs that are defined to run manually should not be triggered automatically.
Output of checks
This bug happens on GitLab.com: 14.5.0-pre 9df5f28f557