2018-06-27 03:23:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-14 06:53:51 -04:00
|
|
|
class BuildFinishedWorker
|
2017-11-28 11:08:30 -05:00
|
|
|
include ApplicationWorker
|
2017-08-21 08:16:51 -04:00
|
|
|
include PipelineQueue
|
|
|
|
|
2017-11-28 11:16:50 -05:00
|
|
|
queue_namespace :pipeline_processing
|
2016-10-14 06:53:51 -04:00
|
|
|
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2016-10-14 06:53:51 -04:00
|
|
|
def perform(build_id)
|
|
|
|
Ci::Build.find_by(id: build_id).try do |build|
|
2019-01-17 10:08:36 -05:00
|
|
|
process_build(build)
|
2016-10-14 06:53:51 -04:00
|
|
|
end
|
|
|
|
end
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2019-01-17 10:08:36 -05: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 16:29:48 -05:00
|
|
|
ChatNotificationWorker.perform_async(build.id) if build.pipeline.chat?
|
2019-01-17 10:08:36 -05:00
|
|
|
end
|
2016-10-14 06:53:51 -04:00
|
|
|
end
|