GitLab CI の設定


Registration tokenの確認

http://gitlab.phper-na14.info/admin/runners へアクセスし"Registration token" を控えておきます。

gitlab-runnerの登録

既に起動している gitlab-runner にログインして設定を行います。

先にmacの方はipアドレスを調べておきましょう

mac

gitlab-ci coordinator URLに指定する gitlab-ceのipアドレスの調べ方

$ docker inspect gitlab-ce | grep IPAddress
            "SecondaryIPAddresses": null,
            "IPAddress": "",
                    "IPAddress": "172.18.0.2",

extra_hostsに指定するgitlab-runner-dockerのipアドレスの調べ方

$ docker network inspect bridge | grep Gateway
                    "Gateway": "172.17.0.1"

さて、準備ができした。

既に起動している gitlab-runner にログインして設定を行います。

$ docker ps
    Name                   Command               State                        Ports
---------------------------------------------------------------------------------------------------------
gitlab-ce       /assets/wrapper                  Up      22/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp
gitlab-runner   /usr/bin/dumb-init /entryp ...   Up

$ docker exec -it gitlab-runner /bin/bash

下記コマンド実行後、対話式で入力しENTERキーを押していきます #以降はコメントですので入力はしないでください

# gitlab-ci-multi-runner register

Running in system-mode.
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/\:

--> http://192.168.99.100/ci # docker toolbox
--> http://172.18.0.2/ci # docker for mac 注)gitlab-ceコンテナのipを指定

Please enter the gitlab-ci token for this runner:

--> cD4zetjQsmVHq-2Zo8qn # 先ほど控えたトークンを入力

Please enter the gitlab-ci description for this runner:

--> [1e57eefd7e33]: ci

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

--> build,test,deploy

Whether to run untagged builds [true/false]:

--> [false]: # 入力なし

Whether to lock Runner to current project [true/false]:

--> [false]: # 入力なし

Registering runner... succeeded                     runner=Rx93N8ie
Please enter the executor: docker, parallels, shell, ssh, virtualbox, docker-ssh, docker+machine, docker-ssh+machine, kubernetes:

--> docker

Please enter the default Docker image (e.g. ruby:2.1):

--> docker:latest

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

続いて不足している設定を追記/変更します。

# vi /etc/gitlab-runner/config.toml

concurrent = 1
check_interval = 0

[[runners]]
  name = "ci"
  url = "http://192.168.99.100/ci"
  token = "a30c281805be2666c8ddb048e0331f"
  executor = "docker"
  [runners.docker]
    tls_verify = false
    image = "docker latest"
変更-->    privileged = true # trueに変更
    disable_cache = false
変更-->    volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"] # 既にvolumesが定義されているので上書きする
    shm_size = 0
追加toolboxの場合-->    extra_hosts = ["gitlab.phper-na14.info:192.168.99.100", "registry.phper-na14.info:192.168.99.100"] # 追記 docker toolbox
追加formacの場合-->    extra_hosts = ["gitlab.phper-na14.info:172.17.0.1", "registry.phper-na14.info:172.17.0.1"] # 追記 docker for mac 注)gitlab-runner-dockerのipを指定 環境によって変わる
  [runners.cache]

# exit

gitlab-runnerの登録確認

http://gitlab.phper-na14.info/admin/runners へアクセスしgitlab-runnerが登録されていることを確認します。

results matching ""

    No results matching ""