2017-03-29 07:49:47 -04:00
|
|
|
class TriggerScheduleWorker
|
2017-03-22 14:54:49 -04:00
|
|
|
include Sidekiq::Worker
|
|
|
|
include CronjobQueue
|
|
|
|
|
|
|
|
def perform
|
2017-03-29 07:49:47 -04:00
|
|
|
Ci::TriggerSchedule.where("next_run_at < ?", Time.now).find_each do |trigger|
|
2017-03-22 14:54:49 -04:00
|
|
|
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)
|
2017-03-22 14:54:49 -04:00
|
|
|
rescue => e
|
|
|
|
Rails.logger.error "#{trigger.id}: Failed to trigger job: #{e.message}"
|
|
|
|
ensure
|
|
|
|
trigger.schedule_next_run!
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|