CI_COMMIT_BEFORE_SHA is all zero in a merge request pipeline

Summary

CI_COMMIT_BEFORE_SHA is all zero in a merge request pipeline. According to the document, it should refer to the commit before the merge request.

Steps to reproduce

  1. Fork a project
  2. Add a job into .gitlab-ci.yml
show_env:
  stage: test
  script:
    - env
  only:
    - merge_requests
  1. Commit, then create a merge request
  2. Check output from job show_env in merge request pipeline

What is the current bug behavior?

Some of the environment variables:

CI_COMMIT_BEFORE_SHA=0000000000000000000000000000000000000000
CI_MERGE_REQUEST_REF_PATH=refs/merge-requests/1/head
CI_MERGE_REQUEST_SOURCE_BRANCH_NAME=master
CI_MERGE_REQUEST_TARGET_BRANCH_NAME=master
CI_MERGE_REQUEST_SOURCE_PROJECT_URL=https://gitlab.xxx/MY_ID/test
CI_MERGE_REQUEST_PROJECT_URL=https://gitlab.xxx/my_group/test

What is the expected correct behavior?

CI_COMMIT_BEFORE_SHA should be a valid commit SHA.

GitLab environment info

gitlab 11.6 gitlab-runner 11.6.1

Assignee Loading
Time tracking Loading