debian-mirror-gitlab/app/workers/pipeline_schedule_worker.rb

20 lines
617 B
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
class PipelineScheduleWorker
include Sidekiq::Worker
include CronjobQueue
def perform
Ci::PipelineSchedule.active.where("next_run_at < ?", Time.now).find_each do |schedule|
begin
Ci::CreatePipelineService.new(schedule.project,
schedule.owner,
ref: schedule.ref)
.execute(save_on_errors: false, schedule: schedule)
rescue => e
Rails.logger.error "#{schedule.id}: Failed to create a scheduled pipeline: #{e.message}"
ensure
schedule.schedule_next_run!
end
end
end
end