GitLab CI/CD: Architecting, Deploying, and Optimizing Pipelines
Architecture Core Concepts
Run Jobs with Shared Runners
In this guide, you'll learn how to configure GitLab CI/CD jobs to run on GitLab-hosted shared runners for Linux, GPU, Windows, and macOS. This approach leverages GitLab’s SaaS runners to simplify maintenance and reduce infrastructure overhead.
Runner Type | Tag Example | Availability |
---|---|---|
Linux | saas-linux-medium-amd64 | Stable |
GPU | saas-gpu-medium | Stable |
Windows | shared-windows | Beta |
macOS | saas-macos-medium-m1 | Beta |
Note
Windows and macOS shared runners are currently in beta and may have limited capacity. Linux runners run on Google Container-Optimized OS VMs with predefined machine specs.
Shared Runner Specifications
GitLab provides detailed specs for each runner type:
GPU-enabled runners include GPU drivers and libraries:
Windows runners support specific OS versions in beta:
Configuring .gitlab-ci.yml
To target these shared runners, add tags
in your pipeline definition. Create or update .gitlab-ci.yml
at the project root:
windows_job:
tags:
- shared-windows
script:
- echo "Windows OS Version"
- systeminfo
linux_job:
tags:
- saas-linux-medium-amd64
script:
- echo "Linux OS Version"
- cat /etc/os-release
macos_job:
tags:
- saas-macos-medium-m1
script:
- echo "MacOS Version"
- system_profiler SPSoftwareDataType
Note
The tags
keyword ensures each job is picked up by the corresponding shared runner. To see all available shared runners, go to Settings → CI/CD → Runners.
Triggering the Pipeline
Commit your changes to the default branch (e.g., main
) to launch the pipeline. You should see three jobs queued in parallel:
Warning
The macOS job may remain pending if there are no active runners. SaaS macOS runners are in beta and reserved for Premium/Ultimate plans.
You can cancel the pending macOS job to let the Linux and Windows jobs finish. The pipeline view updates to show job statuses:
Viewing Job Logs
Linux Job Logs
The Linux job runs on a medium VM using the Docker+machine executor:
$ echo "Linux OS Version"
Linux OS Version
$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
ID=debian
Windows Job Logs
The Windows job spins up a custom VM executor and then runs your commands:
Running with gitlab-runner 16.5.0 (83330f9) on windows-shared-runners-manager...
Preparing the "custom" executor
Getting source from Git repository
Executing "step_script" stage of the job script
Cleaning up project directory and file based variables
Job succeeded
$ echo "Windows OS Version"
Windows OS Version
$ systeminfo
Conclusion
By applying runner tags in your .gitlab-ci.yml
, you can precisely target GitLab’s shared runner environments for Linux, GPU, Windows, and macOS. This setup streamlines cross-platform CI/CD workflows and offloads infrastructure maintenance to GitLab.
Watch Video
Watch video content