Skip to content

GitLab Pipeline Workflow

Introduction

Overview

Our GitLab pipeline workflow provides a standardized approach to continuous integration and deployment. It supports multiple project types and frameworks through specialized templates while maintaining consistent quality and security standards.

Pipeline Architecture

Project Detection and Base Templates

graph TD
    subgraph "Project Detection"
        A[Repository] --> B{Project Type}
        B -->|Single Project| C[Single Config]
        B -->|Monorepo| D[Monorepo Config]
    end

    subgraph "Base Templates"
        E[quality.yml]
        F[security.yml]
    end

    C --> E & F
    D --> E & F

    classDef config fill:#f9f,stroke:#333,stroke-width:2px
    classDef template fill:#bbf,stroke:#333,stroke-width:2px

    class C,D config
    class E,F template

Stack Templates

graph TD
    subgraph "Web"
        G[Next.js]
        H[Nest.js]
    end

    subgraph "Mobile"
        I1[Flutter]
        I2[iOS]
        I3[Android]
    end

    subgraph "API"
        J1[Node.js]
        J2[Python]
    end

    subgraph "Infrastructure"
        K1[Pulumi]
        K2[Terraform]
        K3[CloudFormation]
    end

    C -->|Project Match| G & H
    C -->|Project Match| I1 & I2 & I3
    C -->|Project Match| J1 & J2
    C -->|Project Match| K1 & K2 & K3

    classDef template fill:#bbf,stroke:#333,stroke-width:2px
    class G,H,I1,I2,I3,J1,J2,K1,K2,K3 template

Pipeline Triggers and Stages

graph TD
    subgraph "Change Detection"
        O{Changes}
    end

    subgraph "Project Pipelines"
        P[Web]
        Q[Mobile]
        R[API]
        T[Infrastructure]
        S[Libraries]
    end

    subgraph "Pipeline Stages"
        K[Prepare]
        L[Test]
        M[Build]
        N[Deploy]
    end

    O -->|/apps/web/*| P
    O -->|/apps/mobile/*| Q
    O -->|/apps/api/*| R
    O -->|/infrastructure/*| T
    O -->|/libs/*| S

    P & Q & R & T & S --> K --> L --> M --> N

    classDef stage fill:#bfb,stroke:#333,stroke-width:2px
    class K,L,M,N stage

Template Inheritance

graph TD
    subgraph "Base Configuration"
        A[.gitlab-ci.yml] --> B[Single Project Config]
        A --> C[Monorepo Config]
    end

    subgraph "Base Templates"
        D[quality.yml]
        E[security.yml]
    end

    subgraph "Framework Templates"
        F[nextjs.yml]
        G[nestjs.yml]
        H1[flutter.yml]
        H2[ios.yml]
        H3[android.yml]
        I1[node.yml]
        I2[python.yml]
        J1[pulumi.yml]
        J2[terraform.yml]
        J3[cloudformation.yml]
    end

    B --> D & E
    B -->|Project Type Detection| F & G & H1 & H2 & H3 & I1 & I2 & J1 & J2 & J3

    C --> D & E
    C -->|Path-based Triggers| K[Workspace-specific Pipeline]
    K --> F & G & H1 & H2 & H3 & I1 & I2 & J1 & J2 & J3

    classDef base fill:#f9f,stroke:#333,stroke-width:2px
    classDef template fill:#bbf,stroke:#333,stroke-width:2px

    class A,B,C base
    class D,E,F,G,H1,H2,H3,I1,I2,J1,J2,J3 template

IaC Pipeline Stages

graph TD
    subgraph "IaC Stages"
        A[Validate] --> B[Plan]
        B --> C[Apply]
        C --> D[Destroy]
    end

    subgraph "Validation Steps"
        E1[Lint]
        E2[Security Scan]
        E3[Cost Estimate]
    end

    subgraph "Plan Steps"
        F1[Preview Changes]
        F2[Generate Plan]
        F3[Review Changes]
    end

    subgraph "Apply Steps"
        G1[Create/Update]
        G2[Wait for Completion]
        G3[Verify State]
    end

    A --> E1 & E2 & E3
    B --> F1 --> F2 --> F3
    C --> G1 --> G2 --> G3

    classDef stage fill:#f9f,stroke:#333,stroke-width:2px
    classDef step fill:#bbf,stroke:#333,stroke-width:2px

    class A,B,C,D stage
    class E1,E2,E3,F1,F2,F3,G1,G2,G3 step

Rules and Triggers

graph TD
    subgraph "Trigger Events"
        A[Merge Request]
        B[Default Branch Push]
        C[Tag Creation]
        D[Feature Branch Push]
    end

    subgraph "Pipeline Rules"
        E{Single Project}
        F{Monorepo}
    end

    subgraph "Job Execution"
        G[Run All Stages]
        H[Deploy Stage Skip]
        I[Path-based Pipeline]
    end

    A & B & C & D --> E
    A & B & C & D --> F

    E -->|MR/Default/Tag| G
    E -->|Feature Branch| H

    F -->|Path Changes| I
    I -->|Workspace Match| G
    I -->|No Changes| J[Skip Pipeline]

    classDef event fill:#f9f,stroke:#333,stroke-width:2px
    classDef rule fill:#bbf,stroke:#333,stroke-width:2px
    classDef action fill:#bfb,stroke:#333,stroke-width:2px

    class A,B,C,D event
    class E,F rule
    class G,H,I,J action

Features

Project Type Detection

  1. Automatic detection based on project path and name
  2. Framework-specific template selection
  3. Standardized pipeline stages

Base Templates

  1. Quality checks (linting, testing)
  2. Security scans (SAST, dependency scanning)
  3. Reusable across all project types

Framework Templates

  1. Optimized for specific tech stacks
  2. Custom build and test configurations
  3. Framework-specific best practices

Monorepo Support

  1. Path-based change detection
  2. Independent pipeline triggers
  3. Shared cache configuration
  4. Workspace-specific builds

Pipeline Stages

  1. Prepare: Setup and validation
  2. Test: Quality checks and testing
  3. Build: Compilation and packaging
  4. Deploy: Environment deployments

Smart Rules

  1. Event-based execution
  2. Branch-specific behaviors
  3. Conditional deployments
  4. Change-based triggers

Getting Started

Setup Steps

  1. Choose between single project or monorepo configuration
  2. Follow naming conventions for automatic template selection
  3. Add minimal pipeline configuration to your project
  4. Configure required environment variables

Prerequisites

  1. GitLab Runner with Docker support
  2. Required access tokens and credentials
  3. Project follows standard naming conventions
  4. Appropriate permissions for deployments

Example Usage

YAML
1
2
3
4
5
6
7
include:
  - project: 'stratpoint/engineering-standards'
    ref: main
    file: '/pipelines/ci/gitlab/templates/base/quality.yml'
  - project: 'stratpoint/engineering-standards'
    ref: main
    file: '/pipelines/ci/gitlab/templates/stacks/web/nextjs.yml'