CLOVER🍀

That was when it all began.

GitLab CI/CDパイプラインをローカルで実行できる実験的プロジェクト、glciを試す

これは、なにをしたくて書いたもの?

GitLab CI/CDパイプラインをローカルで実行できるglciというものがあるようなので、試してみたいと思います。

glci?

glciはGitLab CI/CDパイプラインをローカルで実行できる実験的なプロジェクトです。

An experimental GitLab project.

GitLabリポジトリーはこちら。

GitLab.org / ci-cd / runner-tools / glci · GitLab

ドキュメントサイトはこちら。

glci — Run GitLab CI/CD pipelines locally.

ドキュメントはこちら。

Getting Started | glci

確かにGitLab Pagesを見ると、ちょっと実験的な感じがしますね。

GitLab CI/CDパイプラインをローカルで動かしたい?

このお題は過去に扱ったことがあります。

GitLabのジョブをローカルで動かせるgitlab-ci-localを試す - CLOVER🍀

GitLab Runnerのrun-singleコマンドを使って、単一のGitLab CI/CDジョブを実行する - CLOVER🍀

gitlab-ci-localはローカルでGitLab CI/CDパイプラインを動かすもので、GitLab Runnerのrun-singleコマンドは単一のCI/CDジョブを
実行するコマンドです。そして過去にはこれと同じテーマでGitLab Runner自身にexecというコマンドがありましたが、これは
廃止されています。

なのでGitLab自身からこのテーマのツールはもう出てこないと思っていたので、glciの存在はちょっと驚きました。

なぜglciなのか?という、他のツールとの比較も含めたページはこちらです。

Why glci | glci

glciが気にしているポイントは、以下のような結果の信頼性です。

  • GitLab Runnerによる実行を忠実に再現できるか?
  • GitLabを含めた環境を忠実に再現できるか?
  • 実行にかかるコスト(実行速度や費用)

他の実現手段は、これらのどれかを犠牲にしているとしています。

  • GitLab CI/CD上でテストを実行する … CI/CDを実行させるコミットが必要になり、試行に数分かかる
  • ローカルでの再実装(gitlab-ci-localなど) … GitLab Runnerの動作と乖離がある
    • gitlab-ci-local | glci
    • gitlab-ci-localは再実装アプローチのため、GitLab Runnerの更新への追従を求められる
  • gitlab-runner exec … GitLabサーバーなし、1回の実行でひとつのジョブのみを実行できるなど動作に差異が大きい。GitLab Runnerから削除済み
  • ローカル実行用とGitLabとGitLab Runnerを使う … GitLabおよびGitLab Runnerを動作させるためのリソースを消費し、起動にも時間がかかる。本物のGitLabサーバーと同じ設定を再現できないことがある

glciではこれらの問題について、以下のアプローチでできる限り解決しようとしています。

  • gitlab/gitlab-runnerイメージを使って動作する
  • GitLabのモックサーバーを実装しており、APIなどの機能を提供する

完全に解決できているわけではありません。いくつか制限事項があります。

Troubleshooting / Known limitations

ExecutorはDockerのみが利用可能です。

では、簡単に試してみましょう。

環境

今回の環境はこちら。Ubuntu Linux 24.04 LTSです。

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.04.5 LTS
Release:        24.04
Codename:       noble


$ uname -srvmpio
Linux 6.8.0-142-generic #142-Ubuntu SMP PREEMPT_DYNAMIC Wed Sep  2 14:24:27 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux

Docker。

$ docker version
Client: Docker Engine - Community
 Version:           29.8.1
 API version:       1.56
 Go version:        go1.26.8
 Git commit:        4a63305
 Built:             Tue Sep 15 16:26:01 2026
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          29.8.1
  API version:      1.56 (minimum version 1.40)
  Go version:       go1.26.8
  Git commit:       464cd50
  Built:            Tue Sep 15 16:26:01 2026
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v2.3.5
  GitCommit:        1294c24a7da8e5a793ed378161673abe94118892
 runc:
  Version:          1.5.1
  GitCommit:        v1.5.1-0-g8f2685a4
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

GitLabは192.168.0.7で動作しているものとします。

$ sudo gitlab-rake gitlab:env:info

System information
System:         Ubuntu 24.04
Current User:   git
Using RVM:      no
Ruby Version:   3.3.12
Gem Version:    3.7.2
Bundler Version:4.0.18
Rake Version:   13.4.2
Redis Version:  7.2.16
Sidekiq Version:7.3.9
Go Version:     unknown

GitLab information
Version:        19.4.0
Revision:       694ef7184a3
Directory:      /opt/gitlab/embedded/service/gitlab-rails
DB Adapter:     PostgreSQL
DB Version:     17.11
URL:            http://192.168.0.7
HTTP Clone URL: http://192.168.0.7/some-group/some-project.git
SSH Clone URL:  git@192.168.0.7:some-group/some-project.git
Using LDAP:     no
Using Omniauth: yes
Omniauth Providers:

GitLab Shell
Version:        14.57.3
Repository storages:
- default:      unix:/var/opt/gitlab/gitaly/gitaly.socket
GitLab Shell path:              /opt/gitlab/embedded/service/gitlab-shell

Gitaly
- default Address:      unix:/var/opt/gitlab/gitaly/gitaly.socket
- default Version:      19.4.0-gefaa887
- default Git Version:  2.55.0-rc1.g02bb39c

GitLabの操作はTerraformで行います。

$ terraform version
Terraform v1.16.3
on linux_amd64

準備

まずはGitLabにリソースを作成します。Terraformで作成しましょう。

main.tf

terraform {
  required_version = "1.16.3"

  required_providers {
    gitlab = {
      source  = "gitlabhq/gitlab"
      version = "19.4.0"
    }
  }
}

variable "root_access_token" {
  type      = string
  ephemeral = true
}

provider "gitlab" {
  token    = var.root_access_token
  base_url = "http://192.168.0.7/"
}

resource "gitlab_group" "sample_group" {
  name = "sample group"
  path = "sample-group"

  visibility_level = "private"
}

resource "gitlab_project" "sample_app" {
  name         = "sample-app"
  namespace_id = gitlab_group.sample_group.id

  default_branch = "main"

  visibility_level = "private"

  auto_devops_enabled = false

  only_allow_merge_if_pipeline_succeeds            = true
  only_allow_merge_if_all_discussions_are_resolved = true
}

resource "gitlab_branch_protection" "main_branch" {
  project = gitlab_project.sample_app.id
  branch  = "main"

  allow_force_push = false

  merge_access_level = "maintainer"
  push_access_level  = "maintainer"
}

resource "gitlab_group_membership" "sample_user" {
  group_id     = gitlab_group.sample_group.id
  user_id      = gitlab_user.sample_user.id
  access_level = "owner"
}

resource "gitlab_user" "sample_user" {
  name     = "sample-user"
  username = "sample-user"
  password = "P@ssw0rd"
  email    = "sample-user@example.com"
}

resource "gitlab_personal_access_token" "sample_user_token" {
  user_id = gitlab_user.sample_user.id
  name    = "sample-user-pat"

  scopes = ["api"]
}

resource "gitlab_project_variable" "my_variable" {
  project   = gitlab_project.sample_app.id
  key       = "MY_VARIABLE"
  value     = "My Variable"
  protected = true
}

output "user_personal_access_token" {
  value     = gitlab_personal_access_token.sample_user_token.token
  sensitive = true
}

プロジェクト単位のCI/CD変数を定義しています。

resource "gitlab_project_variable" "my_variable" {
  project   = gitlab_project.sample_app.id
  key       = "MY_VARIABLE"
  value     = "My Variable"
  protected = true
}

リソース構築。

$ terraform init
$ terraform apply

GitLabプロジェクトには、この時点ではREADME.mdのみ用意しておきます。

README.md

sample-app

glciをインストールする

glciをインストールします。

必要なものをあらためて確認します。

Prerequisites | glci

DockerまたはPodman、Gitは必須です。任意でGo、glab、makeですね。OSはひととおりサポートしていますが、
WindowsはPodman Desktopの利用が前提になっているようです。

ではインストールします。

$ curl -fsSL https://gitlab.com/gitlab-org/ci-cd/runner-tools/glci/-/raw/main/install.sh | bash

Installation | glci

インストールされました。

==> Detecting platform...
==> Platform: linux/amd64
==> Fetching latest release...
==> Version: v0.8.0
==> Downloading glci-linux-amd64...
==> Installing to /usr/local/bin/glci...
==> Installed glci v0.8.0 to /usr/local/bin/glci
==> Running glci doctor...

  ✓ Docker               docker 29.8.1
  ✓ glci images          5 built-in defaults — set [images] to retarget them
  ~ Daemon               not running (starts automatically on first use)
  ~ GitLab token         not configured (needed only for remote include: and private registries)
  ✗ CI config            .gitlab-ci.yml not found
                         → use -f to point at another file
  ✗ Git repository       not a git repository
                         → cd into your project, or run `git init`

==> Installation complete!
==> Run 'glci' in any GitLab project to get started.

バージョンはコミットハッシュでしかわからないようです。

$ glci version
glci  commit 50516e8ccf85514a484295556f578f9d97437707

インストール時には0.8.0と表示されていましたけどね。

アップグレードもインストール時と同じコマンドを実行するようです。

Installation / Upgrading

ヘルプ。

$ glci help
Run GitLab CI/CD pipelines locally

Usage:
  glci [flags]
  glci [command]

Available Commands:
  artifacts   Manage pipeline artifacts
  completion  Generate the autocompletion script for the specified shell
  config      Manage glci configuration
  daemon      Manage the glci background daemon
  doctor      Check environment health
  help        Help about any command
  history     List pipeline history
  jobs        List available CI jobs
  lint        Validate CI configuration
  log         Show job trace log (streams live if job is running)
  merged      Print the fully-resolved CI configuration
  pages       Manage GitLab Pages artifacts
  ps          List running pipelines and containers
  registry    Manage the embedded container registry
  releases    Manage pipeline releases
  retry       Retry failed jobs from a pipeline
  run         Run pipeline jobs locally
  show        Visualize pipeline without running
  skill       Manage AI agent skills
  stop        Stop running jobs or pipelines
  system      Manage glci system resources
  variables   Show resolved CI/CD variables for each job
  version     Show glci version information

Flags:
  -f, --file string         path to CI config file (default ".gitlab-ci.yml")
      --gitlab-url string   GitLab instance URL (or set GITLAB_URL)
  -h, --help                help for glci
      --project string      GitLab project path (e.g. group/project)
      --token string        GitLab private token (or set GITLAB_TOKEN)

Use "glci [command] --help" for more information about a command.

診断。

$ glci doctor

  ✓ Docker               docker 29.8.1
  ✓ glci images          5 built-in defaults — set [images] to retarget them
  ~ Daemon               not running (starts automatically on first use)
  ~ GitLab token         not configured (needed only for remote include: and private registries)
  ✗ CI config            .gitlab-ci.yml not found
                         → use -f to point at another file
  ✗ Git repository       not a git repository
                         → cd into your project, or run `git init`

GitリポジトリーやCIの設定はこれからです。

glciを使ってみる

それでは、glciを使ってみましょう。

まずは.gitlab-ci.ymlを用意。

.gitlab-ci.yml

stages:
  - build
  - test

workflow:
  rules:
    # Merge Requestを対象
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    # デフォルトブランチを対象
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
    # Protectedブランチを対象
    - if: $CI_COMMIT_REF_PROTECTED == "true"
    # 手動実行
    - if: $CI_PIPELINE_SOURCE == "web"
    # それ以外は実行しない
    - when: never

build-job1:
  stage: build
  image: ubuntu:24.04
  script:
    - |
      echo "Hello World1"

build-job2:
  stage: build
  image: ubuntu:24.04
  script:
    - |
      echo "Hello World2"

test-job:
  stage: test
  image: ubuntu:24.04
  script:
    - |
      echo "Hello Test"

cloneしたGitLabプロジェクト内で、glci doctorコマンドを実行。

$ glci doctor

  ✓ Docker               docker 29.8.1
  ✓ glci images          5 built-in defaults — set [images] to retarget them
  ~ Daemon               not running (starts automatically on first use)
  ~ GitLab token         not configured (needed only for remote include: and private registries)
  ✓ CI config            3 jobs, 4 stages
  ✓ Git repository       main (940fe6c)

Gitリポジトリーの情報を認識しています。

こちらを見ながら、glciを使っていきましょう。

Quick Start | glci

パイプラインの構成を確認。

$ glci show
  Pipeline: 3 jobs across 2 stages

  ○ pending  ● running  ✓ passed  ✗ failed  ▶ manual  ⊘ skipped  ⚠ allow_failure

  build          test
  ────────────── ────────────
  ○ build-job1   ○ test-job
  ○ build-job2

ジョブの確認、lintの実行。

$ glci jobs
JOB         STAGE  WHEN        ALLOW_FAILURE  NEEDS
build-job1  build  on_success
build-job2  build  on_success
test-job    test   on_success


$ glci lint
CI configuration is valid: 3 jobs, 4 stages

glci mergedを使うことで、includeやextendsなどを解決した後の結果を見ることもできるようです。

$ glci merged
build-job1:
  image: ubuntu:24.04
  script:
    - |
      echo "Hello World1"
  stage: build
build-job2:
  image: ubuntu:24.04
  script:
    - |
      echo "Hello World2"
  stage: build
stages:
  - .pre
  - build
  - test
  - .post
test-job:
  image: ubuntu:24.04
  script:
    - |
      echo "Hello Test"
  stage: test
workflow:
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
    - if: $CI_COMMIT_REF_PROTECTED == "true"
    - if: $CI_PIPELINE_SOURCE == "web"
    - when: never

パイプラインを実行。

$ glci run

初回はけっこう時間がかかります。

glci: ⠙ preparing pipeline... [38.2s]

このあたりのイメージは必要になるようです。

$ docker image ls
                                                                                                                                                          i Info →   U  In Use
IMAGE                                                                                             ID             DISK USAGE   CONTENT SIZE   EXTRA
alpine:latest                                                                                     294b683cb724         13MB         3.94MB
gitlab/gitlab-runner:latest                                                                       e859bcedae25        498MB          114MB    U
registry.gitlab.com/gitlab-org/ci-cd/runner-tools/glci:50516e8ccf85514a484295556f578f9d97437707   9f3de8db05b7       67.2MB           22MB    U
tonistiigi/binfmt:latest                                                                          400a4873b838        118MB         32.7MB

実行時のログ。

glci: pipeline #1 prepared [42.4s]
glci: 3 job(s) across 2 stage(s)

── stage: build ──
  ○ build-job1
  ○ build-job2

── stage: test ──
  ○ test-job


── stage: build [42.4s] ──
  ● build-job1
  ● build-job2
3.8s [build-job1] Running with gitlab-runner 19.4.0 (ac11717a)
3.8s [build-job1]   on sample-group/sample-app@1790153121900/default b545c736a, system ID: r_giAo7Q30IhUZ
3.8s [build-job1]   UUID: not supported with this GitLab version
3.8s [build-job1]   feature flags: FF_NETWORK_PER_BUILD:true
3.8s [build-job1] ── Preparing the "docker" executor ──
3.8s [build-job1] Using Docker executor with image ubuntu:24.04 ...
3.8s [build-job1] Using helper image:  registry.gitlab.com/gitlab-org/gitlab-runner/gitlab-runner-helper:x86_64-v19.4.0
3.8s [build-job1] Using effective pull policy of [if-not-present] for container registry.gitlab.com/gitlab-org/gitlab-runner/gitlab-runner-helper:x86_64-v19.4.0
3.8s [build-job1] Pulling docker image registry.gitlab.com/gitlab-org/gitlab-runner/gitlab-runner-helper:x86_64-v19.4.0 ...
3.8s [build-job2] Running with gitlab-runner 19.4.0 (ac11717a)
3.8s [build-job2]   on sample-group/sample-app@1790153121900/default b545c736a, system ID: r_giAo7Q30IhUZ
3.8s [build-job2]   UUID: not supported with this GitLab version
3.8s [build-job2]   feature flags: FF_NETWORK_PER_BUILD:true
3.8s [build-job2] ── Preparing the "docker" executor ──
3.8s [build-job2] Using Docker executor with image ubuntu:24.04 ...
3.8s [build-job2] Using helper image:  registry.gitlab.com/gitlab-org/gitlab-runner/gitlab-runner-helper:x86_64-v19.4.0
3.8s [build-job2] Using effective pull policy of [if-not-present] for container registry.gitlab.com/gitlab-org/gitlab-runner/gitlab-runner-helper:x86_64-v19.4.0
3.8s [build-job2] Pulling docker image registry.gitlab.com/gitlab-org/gitlab-runner/gitlab-runner-helper:x86_64-v19.4.0 ...
8.8s [build-job2] Using docker image sha256:13188cca15a2d44fc621d42da4efb42b81c9527e072d07aab29468dea15af831 for registry.gitlab.com/gitlab-org/gitlab-runner/gitlab-runner-helper:x86_64-v19.4.0 with digest registry.gitlab.com/gitlab-org/gitlab-runner/gitlab-runner-helper@sha256:13188cca15a2d44fc621d42da4efb42b81c9527e072d07aab29468dea15af831 ...
11.8s [build-job1] Using docker image sha256:13188cca15a2d44fc621d42da4efb42b81c9527e072d07aab29468dea15af831 for registry.gitlab.com/gitlab-org/gitlab-runner/gitlab-runner-helper:x86_64-v19.4.0 with digest registry.gitlab.com/gitlab-org/gitlab-runner/gitlab-runner-helper@sha256:13188cca15a2d44fc621d42da4efb42b81c9527e072d07aab29468dea15af831 ...
16.8s [build-job1] Using effective pull policy of [if-not-present] for container ubuntu:24.04
16.8s [build-job1] Pulling docker image ubuntu:24.04 ...
16.8s [build-job2] Using effective pull policy of [if-not-present] for container ubuntu:24.04
16.8s [build-job2] Pulling docker image ubuntu:24.04 ...
24.8s [build-job1] Using docker image sha256:008173c23f95b170204355c12626cb5a965d779a7e1283b09e9cffbb1bf33ca3 for ubuntu:24.04 with digest ubuntu@sha256:008173c23f95b170204355c12626cb5a965d779a7e1283b09e9cffbb1bf33ca3 ...
24.8s [build-job1] ── Preparing environment ──
24.8s [build-job1] Using effective pull policy of [if-not-present] for container sha256:13188cca15a2d44fc621d42da4efb42b81c9527e072d07aab29468dea15af831
24.8s [build-job2] Using docker image sha256:008173c23f95b170204355c12626cb5a965d779a7e1283b09e9cffbb1bf33ca3 for ubuntu:24.04 with digest ubuntu@sha256:008173c23f95b170204355c12626cb5a965d779a7e1283b09e9cffbb1bf33ca3 ...
24.8s [build-job2] ── Preparing environment ──
24.8s [build-job2] Using effective pull policy of [if-not-present] for container sha256:13188cca15a2d44fc621d42da4efb42b81c9527e072d07aab29468dea15af831
29.8s [build-job1] Running on runner-b545c736a-project-4152559732587330370-concurrent-0 via c7d872300f3a...
29.8s [build-job1] ── Getting source from Git repository ──
29.8s [build-job2] Running on runner-b545c736a-project-4152559732587330370-concurrent-1 via c7d872300f3a...
29.8s [build-job2] ── Getting source from Git repository ──
30.8s [build-job1] Gitaly correlation ID: be3a3179825d4354b0d94f7263bb25f7
30.8s [build-job1] Fetching changes...
30.8s [build-job1] Initialized empty Git repository in /builds/p1790153121900/sample-group/sample-app/.git/
30.8s [build-job1] Created fresh repository.
30.8s [build-job1] Checking out f48f266c as detached HEAD (ref is main)...
30.8s [build-job1] Skipping Git submodules setup
30.8s [build-job1] ── Executing "step_script" stage of the job script ──
30.8s [build-job1] Using effective pull policy of [if-not-present] for container ubuntu:24.04
30.8s [build-job1] Using docker image sha256:008173c23f95b170204355c12626cb5a965d779a7e1283b09e9cffbb1bf33ca3 for ubuntu:24.04 with digest ubuntu@sha256:008173c23f95b170204355c12626cb5a965d779a7e1283b09e9cffbb1bf33ca3 ...
30.8s [build-job2] Gitaly correlation ID: 2b475caa917a4bca85a79110b11ded2c
30.8s [build-job2] Fetching changes...
30.8s [build-job2] Initialized empty Git repository in /builds/p1790153121900/sample-group/sample-app/.git/
30.8s [build-job2] Created fresh repository.
30.8s [build-job2] Checking out f48f266c as detached HEAD (ref is main)...
30.8s [build-job2] Skipping Git submodules setup
30.8s [build-job2] ── Executing "step_script" stage of the job script ──
30.8s [build-job2] Using effective pull policy of [if-not-present] for container ubuntu:24.04
30.8s [build-job2] Using docker image sha256:008173c23f95b170204355c12626cb5a965d779a7e1283b09e9cffbb1bf33ca3 for ubuntu:24.04 with digest ubuntu@sha256:008173c23f95b170204355c12626cb5a965d779a7e1283b09e9cffbb1bf33ca3 ...
31.8s [build-job1] $ echo "Hello World1"
31.8s [build-job1] Hello World1
31.8s [build-job2] $ echo "Hello World2"
31.8s [build-job2] Hello World2
32.8s [build-job1] ── Cleaning up project directory and file based variables ──
32.8s [build-job2] ── Cleaning up project directory and file based variables ──
33.3s [build-job2] Job succeeded
  ✓ build-job2 (33.3s)
33.4s [build-job1] Job succeeded
  ✓ build-job1 (33.4s)

── stage: test [1m15s] ──
  ● test-job
3.0s [test-job] Running with gitlab-runner 19.4.0 (ac11717a)
3.0s [test-job]   on sample-group/sample-app@1790153121900/default b545c736a, system ID: r_giAo7Q30IhUZ
3.0s [test-job]   UUID: not supported with this GitLab version
3.0s [test-job]   feature flags: FF_NETWORK_PER_BUILD:true
3.0s [test-job] ── Preparing the "docker" executor ──
3.0s [test-job] Using Docker executor with image ubuntu:24.04 ...
4.0s [test-job] Using effective pull policy of [if-not-present] for container ubuntu:24.04
4.0s [test-job] Using locally found image version due to "if-not-present" pull policy
4.0s [test-job] Using docker image sha256:008173c23f95b170204355c12626cb5a965d779a7e1283b09e9cffbb1bf33ca3 for ubuntu:24.04 with digest ubuntu@sha256:008173c23f95b170204355c12626cb5a965d779a7e1283b09e9cffbb1bf33ca3 ...
4.0s [test-job] ── Preparing environment ──
4.0s [test-job] Using effective pull policy of [if-not-present] for container sha256:13188cca15a2d44fc621d42da4efb42b81c9527e072d07aab29468dea15af831
5.0s [test-job] Running on runner-b545c736a-project-4152559732587330370-concurrent-0 via c7d872300f3a...
5.0s [test-job] ── Getting source from Git repository ──
5.0s [test-job] Gitaly correlation ID: 2e17b7a1a90f4929b35be1c4c421064f
5.0s [test-job] Fetching changes...
5.0s [test-job] Initialized empty Git repository in /builds/p1790153121900/sample-group/sample-app/.git/
5.0s [test-job] Created fresh repository.
5.0s [test-job] Checking out f48f266c as detached HEAD (ref is main)...
5.0s [test-job] Skipping Git submodules setup
6.0s [test-job] ── Executing "step_script" stage of the job script ──
6.0s [test-job] Using effective pull policy of [if-not-present] for container ubuntu:24.04
6.0s [test-job] Using docker image sha256:008173c23f95b170204355c12626cb5a965d779a7e1283b09e9cffbb1bf33ca3 for ubuntu:24.04 with digest ubuntu@sha256:008173c23f95b170204355c12626cb5a965d779a7e1283b09e9cffbb1bf33ca3 ...
7.0s [test-job] $ echo "Hello Test"
7.0s [test-job] Hello Test
7.0s [test-job] ── Cleaning up project directory and file based variables ──
8.5s [test-job] Job succeeded
  ✓ test-job (8.5s)

──────────────────────────────────────────────────
✓ Pipeline PASSED  1m26s
  3 passed

  build
    ✓ build-job1 (33.4s)
    ✓ build-job2 (33.3s)

  test
    ✓ test-job (8.5s)
──────────────────────────────────────────────────

初回はそこそこ時間がかかりましたが、2回目以降はだいぶ時間が短縮されます。

──────────────────────────────────────────────────
✓ Pipeline PASSED  20s
  3 passed

  build
    ✓ build-job1 (10.2s)
    ✓ build-job2 (10.1s)

  test
    ✓ test-job (7.7s)
──────────────────────────────────────────────────

glci doctorで確認すると、Daemonが起動したようです。

$ glci doctor

  ✓ Docker               docker 29.8.1
  ✓ glci images          5 built-in defaults — set [images] to retarget them
  ✓ Daemon               running (pid 1852)
  ✓ Daemon endpoint      unix:///var/run/docker.sock (from the engine's context — not compared)
  ~ GitLab token         not configured (needed only for remote include: and private registries)
  ✓ CI config            3 jobs, 4 stages
  ✓ Git repository       main (940fe6c)

このあたりですね。

$ docker container ls
CONTAINER ID   IMAGE                                                                                             COMMAND                   CREATED          STATUS          PORTS                                             NAMES
c7d872300f3a   gitlab/gitlab-runner:latest                                                                       "/usr/bin/dumb-init …"   34 minutes ago   Up 34 minutes                                                     glci-runner
0b8b90cbbcee   registry.gitlab.com/gitlab-org/ci-cd/runner-tools/glci:50516e8ccf85514a484295556f578f9d97437707   "glci internal mock-…"   35 minutes ago   Up 35 minutes   0.0.0.0:39741->39741/tcp, [::]:39741->39741/tcp   glci-mock

もう少し使ってみましょう。

buildステージのみを実行。

$ glci run --stage build

build-job2ジョブのみを実行。

$ glci run build-job2

実行履歴。

$ glci history
ID     STATUS     STARTED              REF          JOBS
#4     ✓ passed   2026-09-23 17:51     main         1 jobs
#3     ✓ passed   2026-09-23 17:51     main         2 jobs
#2     ✓ passed   2026-09-23 17:47     main         3 jobs
#1     ✓ passed   2026-09-23 17:45     main         3 jobs

ログの確認。

$ glci log

── build-job2 (passed) ──
Running with gitlab-runner 19.4.0 (ac11717a)
  on sample-group/sample-app@1790153121903/default 39ed9def1, system ID: r_giAo7Q30IhUZ
  UUID: not supported with this GitLab version
  feature flags: FF_NETWORK_PER_BUILD:true
── Preparing the "docker" executor ──
Using Docker executor with image ubuntu:24.04 ...
Using effective pull policy of [if-not-present] for container ubuntu:24.04
Using locally found image version due to "if-not-present" pull policy
Using docker image sha256:008173c23f95b170204355c12626cb5a965d779a7e1283b09e9cffbb1bf33ca3 for ubuntu:24.04 with digest ubuntu@sha256:008173c23f95b170204355c12626cb5a965d779a7e1283b09e9cffbb1bf33ca3 ...
── Preparing environment ──
Using effective pull policy of [if-not-present] for container sha256:13188cca15a2d44fc621d42da4efb42b81c9527e072d07aab29468dea15af831
Running on runner-39ed9def1-project-4152559732587330370-concurrent-0 via c7d872300f3a...
── Getting source from Git repository ──
Gitaly correlation ID: 03a24b49fd064610b44e446fd645b54d
Fetching changes...
Initialized empty Git repository in /builds/p1790153121903/sample-group/sample-app/.git/
Created fresh repository.
Checking out 83bd848c as detached HEAD (ref is main)...
Skipping Git submodules setup
── Executing "step_script" stage of the job script ──
Using effective pull policy of [if-not-present] for container ubuntu:24.04
Using docker image sha256:008173c23f95b170204355c12626cb5a965d779a7e1283b09e9cffbb1bf33ca3 for ubuntu:24.04 with digest ubuntu@sha256:008173c23f95b170204355c12626cb5a965d779a7e1283b09e9cffbb1bf33ca3 ...
$ echo "Hello World2"
Hello World2
── Cleaning up project directory and file based variables ──
Job succeeded

指定したパイプラインのIDのログを表示。

$ glci log 2

ジョブを指定してログを表示することもできます。

$ glci log 2 build-job2
Running with gitlab-runner 19.4.0 (ac11717a)
  on sample-group/sample-app@1790153121901/default 6653c60cc, system ID: r_giAo7Q30IhUZ
  UUID: not supported with this GitLab version
  feature flags: FF_NETWORK_PER_BUILD:true
── Preparing the "docker" executor ──
Using Docker executor with image ubuntu:24.04 ...
Using effective pull policy of [if-not-present] for container ubuntu:24.04
Using locally found image version due to "if-not-present" pull policy
Using docker image sha256:008173c23f95b170204355c12626cb5a965d779a7e1283b09e9cffbb1bf33ca3 for ubuntu:24.04 with digest ubuntu@sha256:008173c23f95b170204355c12626cb5a965d779a7e1283b09e9cffbb1bf33ca3 ...
── Preparing environment ──
Using effective pull policy of [if-not-present] for container sha256:13188cca15a2d44fc621d42da4efb42b81c9527e072d07aab29468dea15af831
Running on runner-6653c60cc-project-4152559732587330370-concurrent-0 via c7d872300f3a...
── Getting source from Git repository ──
Gitaly correlation ID: 230634f37b58402b974e873b0505c374
Fetching changes...
Initialized empty Git repository in /builds/p1790153121901/sample-group/sample-app/.git/
Created fresh repository.
Checking out 87c0f6bd as detached HEAD (ref is main)...
Skipping Git submodules setup
── Executing "step_script" stage of the job script ──
Using effective pull policy of [if-not-present] for container ubuntu:24.04
Using docker image sha256:008173c23f95b170204355c12626cb5a965d779a7e1283b09e9cffbb1bf33ca3 for ubuntu:24.04 with digest ubuntu@sha256:008173c23f95b170204355c12626cb5a965d779a7e1283b09e9cffbb1bf33ca3 ...
$ echo "Hello World2"
Hello World2
── Cleaning up project directory and file based variables ──
Job succeeded

.gitlab-ci.ymlを変更して実行してみましょう。こんな感じにしました。コミットはしていません。

$ git diff
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4efd180..79ef8d6 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -20,14 +20,14 @@ build-job1:
   image: ubuntu:24.04
   script:
     - |
-      echo "Hello World1"
+      echo "Hello Local Runner1"

 build-job2:
   stage: build
   image: ubuntu:24.04
   script:
     - |
-      echo "Hello World2"
+      echo "Hello Local Runner2"

 test-job:
   stage: test

実行。

$ glci run

すると、変更が反映されていました。

9.1s [build-job2] $ echo "Hello Local Runner2"
9.1s [build-job2] Hello Local Runner2
9.1s [build-job2] ── Cleaning up project directory and file based variables ──
9.1s [build-job1] $ echo "Hello Local Runner1"
9.1s [build-job1] Hello Local Runner1
9.1s [build-job1] ── Cleaning up project directory and file based variables ──

よいですね。

次は変数を使ってみます。.gitlab-ci.ymlをこのように変更。

.gitlab-ci.yml

stages:
  - build
  - test

workflow:
  rules:
    # Merge Requestを対象
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
    # デフォルトブランチを対象
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
    # Protectedブランチを対象
    - if: $CI_COMMIT_REF_PROTECTED == "true"
    # 手動実行
    - if: $CI_PIPELINE_SOURCE == "web"
    # それ以外は実行しない
    - when: never

build-job1:
  stage: build
  image: ubuntu:24.04
  script:
    - |
      echo "branch: $CI_COMMIT_BRANCH"
      echo "source: $CI_PIPELINE_SOURCE"
      echo "registry: $CI_REGISTRY"
      echo "my var: $MY_VARIABLE"
      echo "Hello World1"

build-job2:
  stage: build
  image: ubuntu:24.04
  script:
    - |
      echo "Hello World2"

test-job:
  stage: test
  image: ubuntu:24.04
  script:
    - |
      echo "Hello Test"

MY_VARIABLEは、Terraformで登録したGitLab CI/CD変数です。

実行。

$ glci run

すると、こういう結果になりました。GitLabに登録した変数は解決できていませんね。

10.0s [build-job1] $ echo "branch: $CI_COMMIT_BRANCH" # collapsed multi-line command
10.0s [build-job1] branch:
10.0s [build-job1] source: merge_request_event
10.0s [build-job1] registry: glci-mock:39741
10.0s [build-job1] my var:
10.0s [build-job1] Hello World1

ここでglciの設定をします。

Configuration | glci

設定ファイルにはユーザー単位のグローバルな設定ファイル(~/.glci/config.toml)とリポジトリーごとの
設定ファイル(.glciconfig.toml)があります。

Configuration Files | glci

.glciconfig.tomlについては、現在のディレクトリーよりも上位のディレクトリーにあれば認識してくれます。

.glciconfig.toml — per-repo overrides, discovered by walking up from the current working directory

今回はこんな感じで作成。ここでGitLabのURLとPersonal Access Tokenを設定することで、GitLabと連携することができます。

.glciconfig.toml

[defaults]
default_branch = "main"

[gitlab]
url = "http://192.168.0.7/"
token = "xxxxx"

glci doctorで確認すると、認識できていることが確認できます。

$ glci doctor

  ✓ Docker               docker 29.8.1
  ✓ glci images          5 built-in defaults — set [images] to retarget them
  ✓ Daemon               running (pid 1852)
  ✓ Daemon endpoint      unix:///var/run/docker.sock (from the engine's context — not compared)
  ✓ GitLab token         ...kqkk
  ✓ CI config            3 jobs, 4 stages
  ✓ Git repository       main (1d214f4)

実行。

$ glci run

今度はGitLab CI/CD変数も使えました。

9.4s [build-job1] $ echo "branch: $CI_COMMIT_BRANCH" # collapsed multi-line command
9.4s [build-job1] branch:
9.4s [build-job1] source: merge_request_event
9.4s [build-job1] registry: glci-mock:39741
9.4s [build-job1] my var: My Variable
9.4s [build-job1] Hello World1

よさそうですね。

今回はこんなところでしょうか。

おわりに

GitLab CI/CDパイプラインをローカルで実行できる実験的プロジェクト、glciを試してみました。

とても簡単な構成で確認しただけですが、他の方法よりはローカルでの再現度が高そうに思います。

とはいえ、実際に使おうと思うともっと複雑な.gitlab-ci.ymlを相手にすることになると思うのでいろいろハマるのでしょう
けれど。Runnerの実行には時間がかかりがちなので、こういう方法が選択肢にあることは押さえておきたいかなと
思います。