What happens:
I have a CI pipeline on a repo with 3 protected branches: master, staging & develop.
The CI has a deploy script that deploys a group of modules on the related environment.
- develop → dev/…
- staging → staging/…
- production → prod/…
All 3 branches are protected
. So as we develop features, we keep merging them with develop
branch which works fine.
When a batch is ready for staging
, we merge develop
branch with staging
branch to deploy the changes on staging
environment. We don’t(can’t) delete develop
branch when merging with staging
. (Remember both branches are protected)
But yet, when the MR is merged, it runs all our dev
environment stop jobs. (Remember it’s a grouped environment)
I wouldn’t want to remove our on_stop
action because we could use a rollback for when there would be a problem with the recently deployed env/module.
Here is a preview of my CI:
deploy:
extends: .only-changes
stage: deploy
image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest
rules:
- if: '$CI_COMMIT_REF_NAME == "develop" || $CI_COMMIT_REF_NAME == "staging"'
when: on_success
- if: $CI_COMMIT_REF_NAME == "master"
when: manual
- when: never
script:
- ...some deployment script
allow_failure: true
environment:
name: $ENVIRONMENT/$MODULE
on_stop: rollback
dependencies:
- build
rollback:
dependencies:
- deploy
environment:
name: $ENVIRONMENT/$MODULE
action: stop
P.S. I’m thinking maybe it has something to do with not setting the deployment_tier
for protected branches or not setting our protected environments
.
What is the expected behavior:
When I merge develop
with staging
, as I don’t delete the source branch, I expect GitLab CI to seep dev
environment.