This document provides an introduction to Gitlab CI and continuous integration/continuous delivery (CI/CD) workflows. It discusses DevOps practices and the benefits of Gitlab CI. It then covers how to set up Gitlab runners, write a basic Gitlab CI configuration file, define jobs, stages, variables and environments. The document demonstrates concepts like Docker integration, artifacts, auto and manual deployments, and stopping deployments. It concludes with a live demo of a Gitlab CI configuration.
3. DevOps
DevOps is a set of software
development practices that combine
software development (Dev) and
information-technology operations
(Ops) to shorten the
systems-development life cycle
while delivering features, fixes, and
updates frequently in close
alignment with business objectives.
5. CI
Continuous Integration
Continuous Integration works to
integrate code from your team in a
shared repository. Developers share
their new code in a Merge (Pull)
Request, which triggers a pipeline to
build, test, and validate the new code
before merging the changes in your
repository.
6. CD
Continuous Deployment
Continuous Delivery delivers CI
validated code to your application.
Together, CI and CD accelerate how
quickly your team can deliver results
for your customers and
stakeholders. CI helps you catch and
reduce bugs early in the
development cycle, and CD moves
verified to your applications faster.
9. Why Gitlab CI
- Integrated: GitLab CI/CD is part of GitLab
- Open source: CI/CD is a part of both the open source GitLab
- Seamless: Part of the single GitLab application
- Scalable: Tests run distributed on separate machines
- Faster results: Each build can be split in multiple jobs that run in parallel on
multiple machines
- Optimized for delivery: multiple stages, manual deploy gates, environments,
and variables
- Easy to learn
11. Gitlab Runner
- To perform the actual build, you need to install GitLab Runner which is
written in Go.
- It can run on any platform for which you can build Go binaries, including
Linux, OSX, Windows, FreeBSD and Docker.
- It can test any programming language including .Net, Java, Python, C, PHP
and others.
- GitLab Runner has many features, including autoscaling, great Docker
support, and the ability to run multiple jobs concurrently.
17. How to use Gitlab CI
- Gitlab CI configuration is stored inside of the repository in file .gitlab-ci.yml
- If repository contains .gitlab-ci.yml, CI run automatically
- You can work on code & CI together and merge them together
- Smallest unit you can run is job, you can group jobs to stages (jobs run in
parallel in stage, stages run in defined order) and stages create pipeline
- You can build binaries, Docker images, deploy to Kubernetes, track
environments and much more.
18. First Gitlab CI Job
# .gitlab-ci.yml
job:
script: echo Hello World from Gitlab CI!
27. Environments
Environment is used to define that a
job deploys to a specific environment.
If environment is specified and no
environment under that name exists, a
new one will be created automatically.