2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

WSL2でgitlab-runnerを実行する

Last updated at Posted at 2021-01-07

はじめに

ローカルマシンにGitLab Runnerを導入してGitLabでCI/CDする方法 でGitLabのCI環境をローカルに立てる方法を記事にしたが、.gitlab-ci.ymlを変更する際、テストのために何回もコミットするのは美しくないと思ったのでgitlab-runnerをローカルで実行できるようにした。今回はその時のメモ。

環境

WSLのバージョン

> wsl -l -v
  NAME                   STATE           VERSION
* Ubuntu-20.04           Running         2
  docker-desktop-data    Running         2
  Ubuntu-18.04           Running         1
  docker-desktop         Running         2

WSLにgitlab-runnerをインストールする

下記を実行する

curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
sudo apt install gitlab-runner

インストールできたか確認

$ gitlab-runner -v
Version:      13.7.0
Git revision: 943fc252
Git branch:   13-7-stable
GO version:   go1.13.8
Built:        2020-12-21T13:47:06+0000
OS/Arch:      linux/amd64

gitlab-runnerを実行

.gitlab-ci.yml のあるディレクトリに移動

cd {your_directory}

ジョブ実行

gitlab-runner exec docker {job_name}

参考

おわりに

これで .gitlab-ci.yml 自体のテストがしやすくなった。

みなさま良きCIライフをお送りください。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?