Build Runnerマシンのセットアップ
Linux VMを作成する(ここではCent OS 7を使用)
* Gitlab Runnerのページで、Gitlab-ciのURLとtokenをメモする
ビルド対象のプロジェクトの設定ページ
->CI/CD
->Runners Settings
Gitlab-Runnerをインストールする
# yumにgitlab-ci-runnerを追加
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash
## プロンプトで停止した場合はCtrl+Cを入力してパスワードを入力する
# gitlab-runnerのインストール
sudo yum install gitlab-runner
# runnerを登録
sudo gitlab-runner register
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
## gitlab runnerのページで表示されるgitlab-ciのURLを入力
## runnerからgitlabにアクセスできる様にNSGやファイアウォールを設定しておくこと
Please enter the gitlab-ci token for this runner:
## gitlab runnerのページで表示されるgitlab-ci tokenを入力
Please enter the gitlab-ci description for this runner:
## Runnerの説明を入力
[hostname-01]:
Please enter the gitlab-ci tags for this runner (comma separated):
## Runnerを識別するタグを入力
Whether to run untagged builds [true/false]:
[false]:
Whether to lock Runner to current project [true/false]:
[false]:
Registering runner... succeeded
runner=xxxxxx
Please enter the executor: virtualbox, docker+machine, kubernetes, docker-ssh, parallels, shell, docker, ssh, docker-ssh+machine:
docker
Please enter the default Docker image (e.g. ruby:2.1):
node:8.10
- Runnersのページで、Active, Can run untagged jobsを選択
.gitlab-ci.ymlファイルをプロジェクトに追加
.gitlab-ci.yml
image: node:8.10
stages:
- build
build-job:
stage: build
script:
- npm install
- script:に記述したコマンドがpush時に実行される