gitlab-org--gitlab-foss/app/workers/trigger_schedule_worker.rb

18 lines
514 B
Ruby
Raw Normal View History

class TriggerScheduleWorker
include Sidekiq::Worker
include CronjobQueue
def perform
Ci::TriggerSchedule.where("next_run_at < ?", Time.now).find_each do |trigger|
begin
2017-03-23 11:18:13 -04:00
Ci::CreatePipelineService.new(trigger.project, trigger.owner, ref: trigger.ref).
execute(ignore_skip_ci: true, scheduled_trigger: true)
rescue => e
Rails.logger.error "#{trigger.id}: Failed to trigger job: #{e.message}"
ensure
trigger.schedule_next_run!
end
end
end
end