Stop dynamic environment when associated branch is deleted on merge

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

Problem to solve

This issue happens when review environments are started and stopped via terraform code. To stop the environment(s), the CI job needs to be able to checkout the current branch and run a terraform destroy.

When 'delete source branch' is enabled for a merge request, and the merge request is merged, the source branch will be deleted before the stop job has a chance to check out the code. This results in a broken environment. The only way to remove it is by manual intervention.

Intended users

Developers

User experience goal

The branch should be deleted only after the stop job has finished.

Is this a cross-stage feature?

No

Links / references

Suggested by customer in Zendesk ticket (internal only)

Edited by 🤖 GitLab Bot 🤖