Gitlab - 3.3.3 What is the pipeline
This lesson defines what a pipeline is in GitLab. The application code is committed; now we want to actually run something on the GitLab side and create our first very basic pipeline. Before we go further, a few clarifications on the terminology.
Jobs and stages
Pipelines are the top-level components of Continuous Integration, Continuous Delivery and Continuous Deployment. Fundamentally, a pipeline is a set of elements chained in series, where each element performs specific tasks. You can picture it as: process A executes tasks 1 and 2, process B runs its own tasks, and so on, until the pipeline ends at process D.
In the GitLab CI/CD context, a pipeline is made of two things:
- Jobs — the most basic element. A job defines what to do: for example a job to test the code, or a job to compile the code.
- Stages — collections of jobs. A stage essentially defines the order in which jobs run. All the jobs of a stage run together; once they all succeed, the pipeline moves on to the next stage. If a job in a stage fails, the next stage is usually not executed and the pipeline ends.
Pipelines are generally executed automatically — no manual action is required once they are defined — but GitLab also allows manual interaction when needed, which we will see later in the course.
A typical 4-stage pipeline and pipeline types
In a complete CI/CD pipeline, the four classic stages in order are usually: test, build, staging and production. This is not a hard standard — depending on the project, you can create more or fewer stages and organize them as you see fit.
Finally, there are several pipeline shapes you can use depending on the project complexity: basic pipelines for simple projects, directed acyclic graph (DAG) pipelines for larger and more complex ones, parent–child pipelines, multi-project pipelines, and so on. The names and complexity differ, but the underlying idea — jobs grouped in stages — is always the same. These were the introductory points on pipelines; in the next video we will create our first simple pipeline using GitLab CI/CD.
Summary
A GitLab pipeline is a foundational component of Continuous Integration, Continuous Delivery, and Continuous Deployment (CI/CD) that automates code building, testing, and deployment through interconnected elements. It consists of jobs (tasks that define what to do) and stages (collections of jobs that determine execution order). Pipelines execute automatically once created and progress through stages sequentially, advancing to the next stage only when all jobs in the current stage succeed.
Key points
- A pipeline in GitLab CI/CD comprises two key components: jobs (the fundamental elements that define specific tasks such as testing or compiling code) and stages (collections of jobs that establish execution order)
- All jobs within a stage must complete successfully before the pipeline advances to the next stage; if any job fails, subsequent stages are typically not executed and the pipeline terminates
- Pipelines are generally executed automatically without user intervention once created, though GitLab also allows manual interaction with pipelines when needed
- Common pipeline stages follow a typical pattern of build, test, staging, and production, but the number and organization of stages can be customized based on specific project requirements
- GitLab supports multiple pipeline types including basic pipelines for simple projects, DAG (Directed Acyclic Graph) pipelines for complex projects, and multi-project pipelines for sophisticated workflows
FAQ
What is the difference between a job and a stage in a GitLab pipeline?
A job is the most fundamental element of a pipeline that defines a specific task (e.g., testing or compiling code), while a stage is a collection of one or more jobs that groups related work together and determines the execution order of those jobs within the pipeline.
What happens if a job fails in a GitLab pipeline?
If a job fails within a stage, the next stage in the pipeline is typically not executed and the pipeline stops, preventing further progression through subsequent stages.
Do pipelines require manual intervention to run?
No, pipelines in GitLab are normally executed automatically and do not require any user intervention once created, though GitLab does provide the ability to manually trigger or interact with pipelines when necessary.