6

I try to set up a scheduled pipeline that runs every 20 mins. I use the customized cron syntax (*/20 * * * *) in the setting, but gitlab doesn't honor this and still runs it every hour.

Is this a gitlab bug or did I miss something?

piggybox
  • 1,689
  • 1
  • 15
  • 19

2 Answers2

13

Check out GitLab schedules: it does mention:

The pipelines won't be executed precisely, because schedules are handled by Sidekiq, which runs according to its interval.

For example, if you set a schedule to create a pipeline every minute (* * * * *) and the Sidekiq worker runs on 00:00 and 12:00 every day (0 */12 * * *), only 2 pipelines will be created per day.

To change the Sidekiq worker's frequency, you have to edit the pipeline_schedule_worker_cron value in your gitlab.rb and restart GitLab.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 2
    Thanks! That works and my last step is `gitlab-ctl reconfigure` instead of `restart` as I'm using the omnibus version. – piggybox Oct 07 '18 at 09:30
  • I have the same issue but I am using a hosted free Gitlab version. Is there any workaround for running a pipeline every 15 mins? – Anshul Tripathi Jul 31 '19 at 20:20
  • @AnshulTripathi The pipeline schedule page I mention (https://docs.gitlab.com/ce/user/project/pipelines/schedules.html) should be available for a hosted free GitLab version though. – VonC Jul 31 '19 at 21:09
  • It says "The pipelines won’t be executed exactly on schedule because schedules are handled by Sidekiq, which runs according to its interval." Since mine is a hosted one so I don't have access to the Gitlab server. I want the pipeline to run every 15 mins. If it is not possible, I would have to change the whole logic which is a bummer. – Anshul Tripathi Aug 01 '19 at 02:25
5

New way for 12.8.X

To change the Sidekiq worker’s frequency: Edit the gitlab_rails['pipeline_schedule_worker_cron'] value in your instance’s gitlab.rb file. The exact line I have checked from gitlab.rb file is

# gitlab_rails['pipeline_schedule_worker_cron'] = "19 * * * *"

So uncomment the line and for example to run every minute do this.

gitlab_rails['pipeline_schedule_worker_cron'] = "* * * * *"

Reconfigure GitLab for the changes to take effect. Then go to job and add this in your job schedule, in this example it will run every 5 minutes :

*/5 * * * *

Older version 10.x.x the good way is. Edit the gitlab_ci['schedule_builds_minute'] = "0" value in your instance’s gitlab.rb file.

Please check the the official page, it's changing offen https://docs.gitlab.com/ce/user/project/pipelines/schedules.html#advanced-configuration

rab
  • 133
  • 2
  • 13
  • Strange, considering this particular setting `schedule_builds_minute` was documented in https://github.com/gitlabhq/omnibus-gitlab/commit/bbbb5001dda1713deb24fed717117434737ccbff, in 2014. Do you have a merge request which documents the new method? – VonC Feb 28 '20 at 17:19
  • @VonC, my bad, I have installed in my lab the last version **gitlab-ce-12.8.1-ce** and the documentation is correct, But for my current version **gitlab-ce-12.6.4-ce** there is not **gitlab_rails['pipeline_schedule_worker_cron']** in gitlab.rb, – rab Feb 29 '20 at 13:24
  • @VonC I think It's because the gitlab.rb file has not be changed when I have done the update from 10.2.x to 12.6.4. Strange issue. – rab Feb 29 '20 at 13:36