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

Should A Student Use ChatGPT To Learn DevOps Instead Of Courses?

As a student looking to learn DevOps, you might be wondering if ChatGPT is a good alternative to traditional courses. While there are some benefits to using…

Read More

Top 10 Digital Signature Software Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, digital transformation has reshaped the way businesses manage documents, sign agreements, and engage with clients. Digital signatures have become an essential component of this…

Read More

Top 10 Graphics Design Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, graphics design tools are more essential than ever for businesses, content creators, designers, and marketers across industries. From creating brand identities and advertising materials…

Read More

Top 10 Presentation Software Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, creating engaging and impactful presentations is more than just slides with bullet pointsโ€”itโ€™s about telling a story, conveying ideas visually, and keeping your audience…

Read More

How to Optimize Your headless CMS for Multilingual Websites

A multilingual site enables a company to internationalize itself to different audiences for better engagement and ultimately, international brand awareness. However, without the proper considerations with the…

Read More

Top 10 AI SEO Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, AI SEO tools have become indispensable for digital marketers, businesses, and content creators aiming to dominate search engine rankings. These tools leverage artificial intelligence…

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