LoginSignup
2
2

More than 3 years have passed since last update.

GitLab CI/CD Schedulesでn分毎実行ができない件の対処法

Posted at

はじめに

GitLab使っていますか?私は大好きです。
GitLab CI/CD使っていますか?私は大好きです。

GitLab CI/CD SchedulesはcronライクにPipelineを定期実行できる便利な機能。
ただし、デフォ設定では毎時15分毎に実行というように設定しても効かない。毎時実行になってしまう。
つまり、15分毎実行にさせたくて*/15 * * * *と設定しても反映されない。
この問題への対処法。

環境

  • GitLab-CE 12.8.1
  • RHEL 7.5

※yum経由でインストール

原因

実は公式ドキュメントに完璧に書かれている。ちゃんと読もう(自分自身への戒め)。

The pipelines won’t be executed exactly on schedule because schedules are handled by Sidekiq, which runs according to its interval.
For example, only two pipelines will be created per day if:
・You set a schedule to create a pipeline every minute (* * * * *).
・The Sidekiq worker runs on 00:00 and 12:00 every day (0 */12 * * *).

To change the Sidekiq worker’s frequency:

  1. Edit the gitlab_rails['pipeline_schedule_worker_cron'] value in your instance’s gitlab.rb file.
  2. Reconfigure GitLab for the changes to take effect.

対処方法

Pipeline schedulesの通り、コンフィグをイジって適用させるだけ。

  1. Edit the gitlab_rails['pipeline_schedule_worker_cron'] value in your instance’s gitlab.rb file.
  2. Reconfigure GitLab for the changes to take effect.

コンフィグ変更

yumでインストールしたgitlab-ceの場合は、/etc/gitlab/gitlab.rbが対象のコンフィグファイル。
他のインストール方法では違うパスになっているかもしれないので適宜読み替えて欲しい。

/etc/gitlab/gitlab.rb
  94 # gitlab_rails['pipeline_schedule_worker_cron'] = "41 * * * *"

↑のコメントを削除し有効化させ、毎分実行状態に書き換える。

/etc/gitlab/gitlab.rb
  94 gitlab_rails['pipeline_schedule_worker_cron'] = "* * * * *"

適用

$ gitlab-ctl reconfigure

これだけで問題なく適用できるが、心配ならGitLab丸ごと再起動させても良い。

$ gitlab-ctl restart

確認

新規にScheduleを作るか、既存Scheduleを編集 -> 保存すれば正しい間隔での実行に書き換わる。

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