Sobes.tech
Junior — Middle

Explain what built-in variables are in the CI/CD automation process and how they are used.

sobes.tech AI

Answer from AI

Built-in variables (environment variables) in CI/CD processes are predefined environment variables provided by the automation system (e.g., Jenkins, GitLab CI, GitHub Actions). They contain information about the current build, commit, branch, user, start time, and other parameters.

Using built-in variables allows:

  • To obtain build context data without manual input.
  • To configure script and step behavior depending on the branch, build number, etc.
  • To pass parameters between pipeline stages.

For example, in GitLab CI, there is a variable CI_COMMIT_BRANCH that contains the name of the branch from which the build was triggered. It can be used in a script as follows:

if [ "$CI_COMMIT_BRANCH" = "main" ]; then
  echo "Deploy to production"
else
  echo "Deploy to testing environment"
fi

Thus, built-in variables simplify configuration and make CI/CD processes more flexible and automated.