Documentation for CI_COMMIT_BEFORE_SHA is incorrect.
The documentation on https://docs.gitlab.com/ee/ci/variables/predefined_variables.html for CI_COMMIT_BEFORE_SHA is incorrect.
It states
The previous latest commit present on a branch before a merge request. Only populated when there is a merge request associated with the pipeline.
However, this variable is populated when there is no merge request associated with the pipeline.