Sobes.tech
Junior

What is your experience working with GitLab CI?

sobes.tech AI

Answer from AI

Worked with GitLab CI in projects related to automation of build, testing, and deployment of applications.

Main tasks:

  • Creating and configuring pipelines: Describing build, test, and deploy stages using .gitlab-ci.yml.
  • Managing runners: Setting up, registering, and scaling Shared and Specific runners (Docker Executor, Shell Executor).
  • Integration with tools: Connecting SonarQube for code analysis, Docker Registry for image storage, Helm for managing deployment in Kubernetes.
  • Pipeline optimization: Speeding up builds through dependency caching and parallel task execution.
  • Implementing CI/CD: git flow Developing continuous integration and delivery strategies, including automatic deployment to various environments (staging, production) upon successful tests.
  • Handling artifacts: Configuring storage and access to build and test results.
  • Deployment automation: Using dpl, GitLab Pages, integrating with Ansible and Terraform for infrastructure.

Configuration examples:

image: docker:latest # Using Docker image for build

services:
  - docker:dind # Running Docker in Docker for container builds

variables:
  DOCKER_REGISTRY: $CI_REGISTRY # Variable for GitLab registry path

stages:
  - build
  - test
  - deploy

build_image:
  stage: build
  script:
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY # Registry login
    - docker build -t $DOCKER_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:$CI_COMMIT_SHA-$CI_COMMIT_REF_SLUG . # Build image with tag
    - docker push $DOCKER_REGISTRY/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:$CI_COMMIT_SHA-$CI_COMMIT_REF_SLUG # Push image to registry
  only:
    - main

run_tests:
  stage: test
  image: python:latest # Using Python image for tests
  script:
    - pip install -r requirements.txt # Install dependencies
    - pytest # Run tests
  only:
    - merge_requests

deploy_staging:
  stage: deploy
  environment:
    name: staging
    url: https://staging.example.com # Staging environment URL
  needs: ["run_tests"] # Dependency on successful tests
  script:
    - # Commands for deploying to staging (e.g., via Helm)
  only:
    - main

deploy_production:
  stage: deploy
  environment:
    name: production
    url: https://example.com # Production URL
  needs: ["deploy_staging"] # Dependency on successful staging deployment
  script:
    - # Commands for deploying to production (manual or scheduled)
  when: manual # Manual trigger for production deployment
  only:
    - main

Aspects worked with:

Aspect Experience
runnersExecutors Docker, Shell
cache Used to speed up builds
artifacts Saving logs, reports, collected artifacts
environments Defining environments for deployment
variables Secret variables, CI/CD variables
rules/only/except Conditional job execution
include Splitting configuration into smaller files
triggers Starting pipelines based on external events
child pipelines Nested pipelines for complex projects
job dependencies Configuring dependencies between jobs

I have a solid understanding of CI/CD principles and can apply GitLab CI to build reliable and automated development and deployment processes.