工具技术

GitLab and GitLab CI/CD

What is GitLab?

GitLab Official Website

GitLab is an integrated DevOps platform that combines:

  • Git repository hosting
  • Source code management
  • Continuous Integration / Continuous Deployment (CI/CD)
  • Issue tracking
  • Code review
  • Project management
  • Package and container registry

Unlike traditional setups that require multiple tools such as Jenkins, Jira, and separate Git servers, GitLab provides an all-in-one solution.

What is GitLab CI/CD?

GitLab CI/CD Documentation

GitLab CI/CD is the built-in automation system inside GitLab.

It automatically performs tasks such as:

  • Building projects
  • Running unit tests
  • Running regression test
  • Running benchmark tests
  • Packaging software
  • Deploying applications
  • Generating reports

whenever developers push code or create merge requests.

Core Concepts

1. Pipeline

A pipeline is an automated workflow.

Typical pipeline flow:

Code Commit
    ↓
Build
    ↓
Test
    ↓
Benchmark
    ↓
Package
    ↓
Deploy

2. .gitlab-ci.yml

GitLab CI/CD pipelines are defined using a YAML configuration file stored directly in the repository.

Example:

stages:
  – build
  – test

build_job:
  stage: build
  script:
    – cmake .
    – make

test_job:
  stage: test
  script:
    – ctest

This approach makes CI/CD pipelines version-controlled and reproducible.

3. GitLab Runner

A Runner is the machine or environment that executes CI/CD jobs.

GitLab Runners can run on:

  • Linux
  • Windows
  • macOS
  • Docker containers
  • Kubernetes clusters

This enables scalable and distributed automation.

Main Advantages of GitLab CI/CD

1. All-in-One Platform

GitLab integrates:

FeatureIncluded
Git RepositoryYes
CI/CDYes
Issue TrackingYes
Merge RequestsYes
WikiYes
Artifact StorageYes
Container RegistryYes

This reduces the need for multiple external systems.

2. Better Integration with Development Workflow

GitLab CI/CD is tightly integrated with Merge Requests.

Example workflow:

Developer creates Merge Request
        ↓
Pipeline automatically starts
        ↓
Build and tests run
        ↓
Benchmark executes
        ↓
Results displayed in Merge Request

This improves code quality and team collaboration.

3. Version-Controlled CI/CD

All pipeline configurations are stored in Git.

Benefits:

  • Easy to track changes
  • Easier collaboration
  • Better reproducibility
  • Simplified maintenance

This is considered a major advantage over older CI systems like Jenkins.

4. Strong Docker and Container Support

GitLab CI/CD has native Docker support.

Example:

image: ubuntu:24.04

build:
  script:
    – apt update
    – apt install -y cmake

Each pipeline can run inside a clean and isolated container environment.

5. Excellent for Automated Testing and Benchmarking

GitLab CI/CD is widely used for:

  • Unit testing
  • Integration testing
  • Regression testing
  • Performance benchmarking
  • Nightly builds

Especially in:

  • C++ projects
  • Game engines
  • CAD software
  • AI infrastructure
  • Multi-platform systems

Typical Workflow

Step 1 — Developer Pushes Code

git push


Step 2 — Pipeline Starts Automatically

GitLab detects changes and triggers the pipeline.


Step 3 — Runner Executes Jobs

Example tasks:

  • Compile source code
  • Run tests
  • Execute benchmarks
  • Generate artifacts

Step 4 — Results Are Reported

GitLab displays:

  • Build status
  • Test reports
  • Benchmark logs
  • Artifacts
  • Failure details

directly in the web interface.

Artifacts

GitLab CI/CD can store generated files such as:

  • Executables
  • Benchmark JSON reports
  • Test logs
  • Screenshots
  • Build packages

Example:

artifacts:
  paths:
    – benchmark.json

Artifacts can later be downloaded or used in later pipeline stages.

Comparison with Jenkins

FeatureGitLab CI/CDJenkins
Integrated with Git platformYesNo
ConfigurationYAMLUI + Groovy
Plugin dependencyLowHigh
Docker supportNativePlugin-based
Pipeline versioningExcellentLimited
Maintenance complexityLowerHigher

Why Many Teams Prefer GitLab CI/CD Today

Modern development teams increasingly prefer GitLab CI/CD because it:

  • simplifies DevOps infrastructure,
  • reduces maintenance burden,
  • improves automation consistency,
  • integrates naturally with Git workflows,
  • scales well for modern software projects.

It is especially popular among engineering-focused teams working on:

  • C++
  • graphics engines
  • CAD systems
  • cloud-native applications
  • AI platforms
  • large-scale automated testing systems

Example Modern Development Stack

A common modern setup is:

GitLab CE
    +
GitLab Runner
    +
Docker
    +
CTest / Google Benchmark
    +
Grafana
    +
InfluxDB

This architecture supports:

  • automated builds,
  • nightly benchmark testing,
  • regression detection,
  • performance monitoring,
  • multi-platform CI/CD workflows.

发表回复