Class: RunPipelineScheduleWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker, PipelineQueue
Defined in:
app/workers/run_pipeline_schedule_worker.rb

Overview

rubocop:disable Scalability/IdempotentWorker

Constant Summary

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY

Constants included from WorkerAttributes

WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Method Summary collapse

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Instance Method Details

#perform(schedule_id, user_id) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord


11
12
13
14
15
16
17
18
# File 'app/workers/run_pipeline_schedule_worker.rb', line 11

def perform(schedule_id, user_id)
  schedule = Ci::PipelineSchedule.find_by(id: schedule_id)
  user = User.find_by(id: user_id)

  return unless schedule && user

  run_pipeline_schedule(schedule, user)
end

#run_pipeline_schedule(schedule, user) ⇒ Object

rubocop: enable CodeReuse/ActiveRecord


21
22
23
24
25
26
27
28
29
30
# File 'app/workers/run_pipeline_schedule_worker.rb', line 21

def run_pipeline_schedule(schedule, user)
  Ci::CreatePipelineService.new(schedule.project,
                                user,
                                ref: schedule.ref)
    .execute!(:schedule, ignore_skip_ci: true, save_on_errors: false, schedule: schedule)
rescue Ci::CreatePipelineService::CreateError
  # no-op. This is a user operation error such as corrupted .gitlab-ci.yml.
rescue => e
  error(schedule, e)
end