Sobes.tech
Senior

How are CI/CD pipelines described and operated in GitLab?

sobes.tech AI

Answer from AI

GitLab CI/CD pipelines are described in the .gitlab-ci.yml file, located at the root of the repository. This file contains a set of jobs grouped into stages, which are executed sequentially or in parallel depending on the configuration.

Main elements:

  • stages — defines the sequence of stages, for example: build, test, deploy.
  • jobs — individual tasks that are executed at a specific stage. Each task is described with a script, Docker image (if needed), conditions for execution, and other parameters.

Example of a simple pipeline:

stages:
  - build
  - test
  - deploy

build_job:
  stage: build
  script:
    - echo "Building the project"

test_job:
  stage: test
  script:
    - echo "Running tests"

deploy_job:
  stage: deploy
  script:
    - echo "Deploying application"
  when: manual  # manual trigger

GitLab Runner executes these tasks, and the results are displayed in the GitLab interface. Pipelines can be configured to run on events (push, merge request), with conditions, environment variables, artifacts, and much more.