GitLab Runner登録手順

GitLabでCI/CDやるならRunnerは必須でしょ!
と言う事でRunner登録行ってみよ!
今回はRunnerをDockerで動かすためDockerのインストールも含めます。

Dockerのインストール

$ sudo yum install -y docker
$ sudo systemctl enable docker
$ sudo systemctl start docker

GitLab Runnerのインストール

$ sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
$ sudo chmod +x /usr/local/bin/gitlab-runner
$ sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
$ sudo /usr/local/bin/gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
$ sudo systemctl enable gitlab-runner
$ sudo systemctl start gitlab-runner

GitLab Runnerの登録

トークン確認

サイドバーの「設定」>「CI/CD」>「Runner」項目の”展開”をクリックすると設定画面が現れますので黒塗りのトークンをメモっておきます。
f:id:kyamisama:20201224114725j:plain

トークンの登録

トークン登録は一連の会話形式で登録します。下記にログ残します。

[root@root aws-terraform]# gitlab-runner register
Runtime platform                                    arch=amd64 os=linux pid=27105 revision=943fc252 version=13.7.0
Running in system-mode.

Enter the GitLab instance URL (for example, https://gitlab.com/):
http://192.168.250.52
Enter the registration token:
*******
Enter a description for the runner:
[root.*********.local]: shell-runner 
Enter tags for the runner (comma-separated):
shell
Registering runner... succeeded                     runner=-xKw1Xmy
Enter an executor: docker+machine, docker-ssh+machine, kubernetes, custom, docker, parallels, shell, docker-ssh, ssh, virtualbox:
docker
Enter the default Docker image (for example, ruby:2.6):
hashicorp/terraform:latest
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
[root@root aws-terraform]#

Runner登録確認

再度Runner画面を開き、Runnerが登録されていることを確認する。
f:id:kyamisama:20201224115245j:plain