Sobes.tech
Junior — Middle

What are pre-defined variables in the context of GitLab CI/CD?

sobes.tech AI

Answer from AI

In GitLab CI/CD, predefined variables are special environment variables that are automatically created and available during the pipeline execution. They contain information about the current project, commit, branch, user, and other parameters that help configure and manage the build and deployment process.

For example, the variable CI_COMMIT_SHA contains the hash of the current commit, and CI_PROJECT_NAME is the name of the project. Using these variables allows writing universal scripts that adapt to the specific pipeline run without manual data entry.

An example of usage in .gitlab-ci.yml:

build_job:
  script:
    - echo "Building project $CI_PROJECT_NAME, commit $CI_COMMIT_SHA"

A full list of predefined variables can be found in the official GitLab documentation.