`on_stop` jobs being created when they are not needed

Summary

I use environment.on_stop to setup stop_review jobs and found out GitLab CI created a lot of unnecessary jobs. There are two types:

  1. A new job is created for each new commit to the branch. Upon branch removal, only the last stop_review job is trigger.

  2. A job is created for branches specified in except (e.g. the master branch). The dynamic environment show up in the list with the note "No deployments yet".

Steps to reproduce

Use this yml https://gitlab.com/daohoangson/ci-on-stop/blob/develop/.gitlab-ci.yml

Example Project

https://gitlab.com/daohoangson/ci-on-stop/

What is the current bug behavior?

  1. stop_review jobs are created for each commit of the branch

  2. stop_review job is created for the master branch

What is the expected correct behavior?

  1. Only one stop_review job should be created for each branch

  2. No stop_review job should be created for the master branch

Relevant logs and/or screenshots

Screen_Shot_2018-04-04_at_4.54.31_PM

Output of checks

This bug happens on GitLab.com