DevOps / CI/CD pipelines

CI/CD pipelines

Základy softvérového inžinierstva a DevOps

Sergej Chodarev (sergejx.net)

CI/CD

CI/CD Services

GitLab CI/CD

GitLab CI/CD

YAML

key: value
nested:
  person:
    name: John
    age: 30
list:
  - item 1
  - item 2
inline-list: [item 1, item 2]
strings: "hello world"
quotation-marks: not required
numbers: 42
booleans:
  - true
  - false
  - yes
  - no
# Comments

Caveats

.gitlab-ci.yml

Stages

stages:
  - build
  - test
  - deploy

Jobs

compile:
  stage: build
  script:
    - echo "Compiling the code..."
    - gcc main.c -o main

How the job is executed?

GitLab Runners

Docker Image

compile:
  stage: build
  image: gcc:latest
  script:
    - echo "Compiling the code..."
    - gcc main.c -o main

What with the results?

Status of the job

Artifacts

Artifacts

compile:
  stage: build
  image: gcc:latest
  script: 
    - gcc main.c -o main
  artifacts:
    paths:
      - main

Default settings

default:
  image: python:3.9  # default image for all jobs
  before_script:     # run before each job
    - pip install -r requirements.txt

CI/CD variables

How to use variables?

variables:
  PRODUCTION_SERVER: "prod.example.com"
deploy:
  stage: deploy
  script:
    - echo "Deploying to $PRODUCTION_SERVER server..."
    - scp main user@$PRODUCTION_SERVER:/path/to/deploy

Secrets

Conclusion