Skip to content

CI_COMMIT_SHA called CI_COMMIT_REF in documentation and when using `gitlab-runner exec`

Summary

In the documentation on https://gitlab.com/help/ci/variables/README.md#predefined-variables-environment-variables the name of the variable holding the SHA of the current commit is stated as CI_COMMIT_SHA. Before 9.0 it was CI_BUILD_REF.

  1. In the documentation (docs/shells/README.md) it is called CI_COMMIT_REF instead.
  2. When executing a job locally using gitlab-runner exec, the wrong name is used as well, CI_COMMIT_REF is set but not CI_COMMIT_SHA.

Steps to reproduce

  1. Docs
$ grep -r -w CI_COMMIT_REF *                                                                                               gitlab-runner[master]-
docs/shells/README.md:SET CI_COMMIT_REF=db45ad9af9d7af5e61b829442fd893d96e31250c
docs/shells/README.md:SET CI_COMMIT_REF=db45ad9af9d7af5e61b829442fd893d96e31250c
docs/shells/README.md:SET CI_COMMIT_REF=db45ad9af9d7af5e61b829442fd893d96e31250c
docs/shells/README.md:  $CI_COMMIT_REF="db45ad9af9d7af5e61b829442fd893d96e31250c"
docs/shells/README.md:  $env:CI_COMMIT_REF=$CI_COMMIT_REF
docs/shells/README.md:  $CI_COMMIT_REF="db45ad9af9d7af5e61b829442fd893d96e31250c"
docs/shells/README.md:  $env:CI_COMMIT_REF=$CI_COMMIT_REF
docs/shells/README.md:  $CI_COMMIT_REF="db45ad9af9d7af5e61b829442fd893d96e31250c"
docs/shells/README.md:  $env:CI_COMMIT_REF=$CI_COMMIT_REF
network/gitlab_test.go: cache[0]["key"] = "$CI_COMMIT_REF"
  1. Create a small test project, commit and run gitlab-runner exec docker test
$ cat .gitlab-ci.yml                                                                                                                              
test:
  image: busybox
  script:
    - set | grep CI_COMMIT

Actual behavior

Output of run shows:

$ set | grep CI_COMMIT
CI_COMMIT_BEFORE_SHA='0000000000000000000000000000000000000000'
CI_COMMIT_REF='fd90bc81504b98e7e86d12b18697b165ffde5d2e'
CI_COMMIT_REF_NAME='master'

Expected behavior

Output of run shows:

$ set | grep CI_COMMIT
CI_COMMIT_BEFORE_SHA='0000000000000000000000000000000000000000'
CI_COMMIT_SHA='fd90bc81504b98e7e86d12b18697b165ffde5d2e'
CI_COMMIT_REF_NAME='master'

Relevant logs and/or screenshots

Environment description

Probably not relevant GitLab-Runner 10.8.0 on macOS 10.13.4, Docker 18.05.0-ce-mac66

Used GitLab Runner version

$ gitlab-runner --version                                                                                                                         
Version:      10.8.0
Git revision: 079aad9e
Git branch:   10-8-stable
GO version:   go1.10.2
Built:        2018-05-22T06:05:56+01:00
OS/Arch:      darwin/amd64
Edited by Mirko Friedenhagen