Search code examples
gitlabgitlab-cigitlab-ci-runnergitlab-8

Retrieving push metainformation and transferring it to the CI


I know, that in general GitLab CI scripts run after every push to the repository. How I can retrieve metainforation about the push and then transfer it to the GitLab CI?

By metainforation I mean:

  • project name,
  • name of the user, who performed this push,
  • name of the branch (branches) affected by push.

Solution

  • You can find an overview of variables available in the CI here: https://docs.gitlab.com/ee/ci/variables/#predefined-variables-environment-variables.

    E.g.:

    • CI_COMMIT_REF_NAME | The branch or tag name for which project is built
    • CI_PROJECT_NAME | The project name that is currently being built (actually it is project folder name)
    • GITLAB_USER_ID | The id of the user who started the job
    • GITLAB_USER_EMAIL | The email of the user who started the job