1
0

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.

GitLabRunner環境設定

Last updated at Posted at 2021-10-28

GitLabRunnerとは

GitlabのCI/CDと連携してpiplineで処理を実行するアプリケーションです。
環境を用意し、処理内容をGitlabのリポジトリ内に格納することで、用意した環境での処理実行結果をGitLabで確認することができます。
リポジトリに更新を入れるたびに自動でコンパイルを行うことなどもできます。

環境

  • RunnerServer Ubuntu18.04
  • Gitlab-Runner 14.0.0

イメージ図

runner.png

用意するもの

  • 実行する環境のImage

処理用のコンテナを立ち上げるために使用します。

  • サーバ

上記のイメージを使用してコンテナを立ち上げるために使用します。
サーバは無くてもGitLabが用意しているもので行うこともできますが、環境の問題や月ごとの使用制限等が問題になる場合は用意が必要です。

  • 処理を記載したymlファイル

立ち上げたコンテナ内で処理を走らせるために使用します。

設定方法

GitLabRunnerのインストール

RunnerServerにGitLabRunnerをインストールします。

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

Runnerの登録

処理を行うサーバとプロジェクトを結びつけます。

sudo gitlab-runner register

入力画面になるため、環境に合わせて設定を入力していきます。
今回はDockerでImageを作成します。

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
# プロジェクトURL

Please enter the gitlab-ci token for this runner:
# プロジェクトTOKEN

Please enter the gitlab-ci description for this runner:
# runnerの説明

Please enter the gitlab-ci tags for this runner (comma separated):
# tag

Registering runner... succeeded                     runner=2syNsUzh
Please enter the executor: docker, docker-ssh, virtualbox, docker-ssh+machine, kubernetes, custom, para$ lels, shell, ssh, docker+machine:
# executorType

Please enter the default Docker image (e.g. ruby:2.6):
# デフォルトで使用されるイメージ

Runner registered successfully. Feel free to start it, but if it's running already the config should be

URLとTOKENはプロジェクトのSeettings>CI/CD>Runnsers settingsから確認することができます。

Runnsers_settings.png

URLTOKEN.png

Imageの登録

今回はDockerでImageを作成します。
環境のDockerFileを作成し、ビルド、gitlabへのpushを行います。
登録についてはGitLabのプロジェクト、Packages & Registries > Container Registryにて確認できます。
push後、同ページでimageが確認できれば登録が完了しています。

docker build -t registry.gitlab.com/<group_ID>/<subgroup_ID>/<project_name>:tag> .
docker push registry.gitlab.com/<group_ID>/<subgroup_ID>/<project_name>:<tag>

参考資料

GitLab Docs GitLab Runner

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?