2018-06-27 07:23:28 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-14 10:53:51 +00:00
|
|
|
class BuildFinishedWorker
|
2017-11-28 16:08:30 +00:00
|
|
|
include ApplicationWorker
|
2017-08-21 12:16:51 +00:00
|
|
|
include PipelineQueue
|
|
|
|
|
2017-11-28 16:16:50 +00:00
|
|
|
queue_namespace :pipeline_processing
|
2016-10-14 10:53:51 +00:00
|
|
|
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2016-10-14 10:53:51 +00:00
|
|
|
def perform(build_id)
|
|
|
|
Ci::Build.find_by(id: build_id).try do |build|
|
2019-01-17 15:08:36 +00:00
|
|
|
process_build(build)
|
2016-10-14 10:53:51 +00:00
|
|
|
end
|
|
|
|
end
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2019-01-17 15:08:36 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
# Processes a single CI build that has finished.
|
|
|
|
#
|
|
|
|
# This logic resides in a separate method so that EE can extend it more
|
|
|
|
# easily.
|
|
|
|
#
|
|
|
|
# @param [Ci::Build] build The build to process.
|
|
|
|
def process_build(build)
|
|
|
|
# We execute these in sync to reduce IO.
|
|
|
|
BuildTraceSectionsWorker.new.perform(build.id)
|
|
|
|
BuildCoverageWorker.new.perform(build.id)
|
|
|
|
|
|
|
|
# We execute these async as these are independent operations.
|
|
|
|
BuildHooksWorker.perform_async(build.id)
|
|
|
|
ArchiveTraceWorker.perform_async(build.id)
|
2019-02-20 21:29:48 +00:00
|
|
|
ChatNotificationWorker.perform_async(build.id) if build.pipeline.chat?
|
2019-01-17 15:08:36 +00:00
|
|
|
end
|
2016-10-14 10:53:51 +00:00
|
|
|
end
|