Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

โ€œInvest in yourself โ€” your confidence is always worth it.โ€

Explore Cosmetic Hospitals

Start your journey today โ€” compare options in one place.

GitLab CI/CD Execution Hierarchy

Understanding the hierarchy, precedence, sequencing, and parallelism in GitLab CI/CD pipelines is crucial to mastering how your jobs run, how to optimize them, and how GitLab decides what to execute and when.

Hereโ€™s a complete and up-to-date (GitLab 18.0, May 2026) breakdown of the GitLab pipeline execution model:


๐Ÿงฑ 1. ๐Ÿ”„ GitLab CI/CD Execution Hierarchy

โžค Pipeline (Top-Level Entity)

A single run of your .gitlab-ci.yml file. Triggered by:

  • Push/merge/tag
  • Schedule
  • Manual trigger
  • API call

โžค Stages (Sequential Execution Layer)

Defines the order of execution โ€” each stage completes fully before the next begins.

stages:
  - lint
  - test
  - build
  - deploy

โžค Jobs (Inside Each Stage)

All jobs within a stage run in parallel, provided runners are available.

lint:
  stage: lint
  script: npm run lint

unit_test:
  stage: test
  script: npm test

โžค Steps inside a Job

Each jobโ€™s script: section contains commands that run sequentially inside the job’s shell or container.


๐Ÿ”ƒ 2. Pipeline Execution Flow

Pipeline
 โ”œโ”€โ”€ Stage 1: lint
 โ”‚    โ”œโ”€โ”€ job: lint_a  (parallel)
 โ”‚    โ””โ”€โ”€ job: lint_b  (parallel)
 โ”œโ”€โ”€ Stage 2: test
 โ”‚    โ”œโ”€โ”€ job: unit_tests
 โ”‚    โ””โ”€โ”€ job: integration_tests
 โ”œโ”€โ”€ Stage 3: build
 โ”‚    โ””โ”€โ”€ docker_build
 โ””โ”€โ”€ Stage 4: deploy
      โ”œโ”€โ”€ job: staging_deploy
      โ””โ”€โ”€ job: prod_deploy (manual)

โฑ๏ธ 3. Job Precedence & Order of Execution

โœ… Within a Stage:

  • Jobs run in parallel
  • No strict order unless using needs: (see below)

โœ… Between Stages:

  • Sequential: Stage 2 starts only if all Stage 1 jobs succeed

โšก 4. How to Run Jobs in Parallel or Control Order

๐Ÿ”น Parallel Jobs

Jobs in the same stage naturally run in parallel. Example:

test_backend:
  stage: test
  script: run backend tests

test_frontend:
  stage: test
  script: run frontend tests

๐Ÿ”น Needs: (Run jobs out-of-order / faster)

Allows stage-skipping and job-level dependency. Ideal for reducing pipeline time.

unit_test:
  stage: test
  script: run tests

docker_build:
  stage: build
  script: build docker
  needs: [unit_test]   # Doesn't wait for whole test stage
Code language: PHP (php)

๐Ÿ”น Dependencies (Job artifact consumption, older method)

Specify jobs that must complete before current job can use their artifacts.

deploy:
  stage: deploy
  dependencies: [build]
Code language: CSS (css)

๐Ÿ” Use needs: for parallel dependency-based optimization
๐Ÿ“ฆ Use dependencies: to pass artifacts


๐Ÿงช 5. Conditional Execution (Job-Level Control)

๐Ÿ”ธ Rules

Recommended way to control job execution with complex conditions.

job_a:
  rules:
    - if: '$CI_COMMIT_BRANCH == "main"'
Code language: JavaScript (javascript)

๐Ÿ”ธ only/except (Deprecated in favor of rules)

job_b:
  only:
    - branches
    - tags

๐ŸŽฏ 6. Extended Structures

StructurePurposeNotes
Parent-Child PipelinesModularize pipelines (include from other .yml)Ideal for monorepos
Multi-project PipelinesTrigger another projectโ€™s pipelineGood for microservice chaining
IncludesReuse YAML templatesFrom same repo or remote

๐Ÿ“‹ 7. Visual: GitLab CI/CD Execution Hierarchy

Pipeline
โ”œโ”€โ”€ Stages (sequential)
โ”‚   โ”œโ”€โ”€ Jobs (parallel unless controlled)
โ”‚   โ”‚   โ”œโ”€โ”€ Scripts (sequential commands)
โ”‚   โ”‚   โ””โ”€โ”€ Artifacts/Needs/Dependencies
โ”œโ”€โ”€ Includes / Child Pipelines (optional)
โ””โ”€โ”€ Triggered Pipelines (optional)

โœ… Summary: Controlling Flow & Parallelism

Control MechanismUsed For
stages:Define sequential job groupings
needs:Define parallel dependencies
rules:Fine-grained control of job triggers
when:Delay, manual, or conditional jobs
only/exceptBasic conditions (legacy)
dependencies:Artifact-based job dependencies
trigger:Trigger child or multi-project pipelines

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

Team Foundation Server 2015 Installation Guide (SQL Express + Update 3)

Install Team Foundation Server 2015 using the original Microsoft download paths, with clear guidance for online, offline, and ISO-based setup. This revised guide also includes an installation workflow, command example, and practical pitfalls to avoid.

Read More

How to Access a Running Docker Container Shell: docker exec vs docker attach

Need a shell inside a running container that is already in detached mode? This updated guide shows the correct workflow, compares docker exec and docker attach, and explains when SSH does and does not make sense.

Read More

Host Your Own NuGet Feed: Local Source vs NuGet.Server vs NuGetGallery

Learn how to host a private NuGet feed using three practical approaches: a local folder source, NuGet.Server, and NuGetGallery. This revised guide includes setup steps, command examples, and a workflow diagram to help you choose the right model.

Read More

Publish NuGet Packages to NuGet.org: CLI Steps, Workflow, and CI Example

Learn how to publish a NuGet package to NuGet.org using either nuget.exe or the dotnet CLI. This revised guide includes a workflow diagram, command comparison, and a CI-friendly example.

Read More

How to Create NuGet Packages with nuget.exe (Assembly, .nuspec, and .csproj Methods)

Learn three practical ways to build NuGet packages using nuget.exe: from an existing assembly, from a convention-based folder layout, or directly from a Visual Studio project. This guide includes commands, folder conventions, token behavior, and common pitfalls.

Read More

Virtualization in DevOps: Using Vagrant, Docker, and Cloud Platforms Together

This guide explains how VM-based workflows, containers, and cloud platforms complement each other in DevOps. It includes a practical workflow, trade-off table, and command examples for day-to-day use.

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x