DevOps
GitLab CI/CD
GitLab CI/CD is the build and delivery system built into GitLab, configured with a .gitlab-ci.yml file.
What it is
GitLab CI/CD is part of the GitLab platform, which also includes the repository, code review, container registry and security. Built-in CI integration arrived in GitLab 8.0 in 2015.
A pipeline is described in .gitlab-ci.yml at the repo root: stages set the order, jobs within a stage run in parallel, and they are executed by runners you can install on your own servers. It has artifacts, cache, environments, merge request pipelines and Auto DevOps.
GitLab can be self-hosted (Community Edition under MIT) or used as GitLab.com. It is a popular choice for companies that want code and CI in their own infrastructure.
Use it when
- Your code is in GitLab and you want CI without another service.
- You need a self-hosted platform with repository, CI and registry in one place.
- You need merge request pipelines and built-in security scanning.
Avoid it when
- Your code is on GitHub: GitHub Actions is the more natural choice.
- You need only the simplest builds and the whole GitLab platform is overkill.
Key concepts
- Pipeline / stage / job
- A pipeline is a set of stages, a stage is a group of parallel jobs, a job is one task.
- Runner
- The agent that runs jobs: shared by GitLab or your own.
- Artifacts / cache
- Artifacts pass results between stages, cache speeds up repeated builds.
- Environments
- Named deploy targets (staging, production) with deploy history.
Example
Interview questions
1. What is a runner in GitLab?
A process that takes jobs from GitLab and executes them, in a shell, Docker or Kubernetes. GitLab provides shared runners, and you can register your own on your servers.
2. How do you pass files between stages?
Through artifacts: a job saves files and later stages receive them automatically. Cache is meant for dependencies across runs, not for passing results.
3. How does GitLab CI differ from Jenkins?
GitLab CI is built into the platform and configured with YAML in the repo. Jenkins is a separate server with plugins and a Jenkinsfile, more flexible but needing more maintenance.
Interview questions from the bank
Comparisons with this technology
Related technologies
- GitHub ActionsGitHub Actions is CI/CD built into GitHub: YAML workflows run on repository events such as push or pull request.
- JenkinsJenkins is an open source automation server for CI/CD with a huge plugin ecosystem and pipelines as code.
- DockerDocker packages an application with its dependencies into a container that runs the same on a laptop, a server and the cloud.
- KubernetesKubernetes is a container orchestration system that deploys, scales and heals applications across a cluster of servers.
Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).