5
5

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 5 years have passed since last update.

Self-Managed な社内 Gitlab をhttps化 したら Gitlab Runnerがうまく動かなかった件

Posted at

はじめに

社内で立ててる Self-Managed な Gitlab を https 化した際、 Gitlab Runner も設定変更が必要です。ところがうまく行かなくて、試行錯誤したので、忘備録的な意味合いで記事を書きます。

今回起きた現象

単純にrunnerのURLだけ変更すれば良いのかと思ってたので、設定変更しました

$ sudo vi /etc/gitlab-runner/config.toml

変更前

[[runners]]
  name = "for server"
  url = "http://192.XXX.XXX.XXX/"
  token = "xxxxxxxxxxxxxxxxxxxx"
  executor = "docker"
  [runners.docker]
    tls_verify = false
    image = "php:7.2.10"
    privileged = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0
  [runners.cache]

変更後


[[runners]]
  name = "for server"
  url = "https://gitlab.hoge.com/" # URLを変更
  token = "xxxxxxxxxxxxxxxxxxxx"
  executor = "docker"
  [runners.docker]
    tls_verify = false
    image = "php:7.2.10"
    privileged = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0
  [runners.cache]

設定を反映します

$ sudo gitlab-runner restart

Jobを走らせます

...(略)...
Fetching changes...
fatal: remote origin already exists.
Clean repository
fatal: unable to access 'http://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@192.XXX.XXX.XXX/nishioka/hoge.git/': Failed to connect to 192.XXX.XXX.XXX port 80: Operation timed out
ERROR: Job failed: exit code 1

あれ?古いURL見に行ってるぞ?

試行錯誤

対策1

たぶん Runner 側にキャッシュが残ってるのかなあとは思ったんで、runners.docker>disable_cachetrueにして runner restart したところうまく行かず。

対策2

Runner の設定値にclone_urlというのがあったのでこれで試しにURLを上書きしてみました。

clone_urlについての詳細はgitlab公式サイトのこの辺に記載があります。
https://docs.gitlab.com/runner/configuration/advanced-configuration.html#how-clone_url-works

[[runners]]
  name = "for server"
  url = "https://gitlab.hoge.com/" # URLを変更
  token = "xxxxxxxxxxxxxxxxxxxx"
  executor = "docker"
  clone_url = "https://gitlab.hoge.com/" # 新たに追加
  [runners.docker]
    tls_verify = false
    image = "php:7.2.10"
    privileged = false
    disable_cache = false
    volumes = ["/cache"]
    shm_size = 0
  [runners.cache]

これで runner restart して動かしました。うごいた!

終わりに

なんでこれで動くのかはわかるのですが抜本的な対策になっていないような気がします。が、ひとまずこれまで。

5
5
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
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?