2018-06-27 03:23:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-02-19 13:09:10 -05:00
|
|
|
class BuildFinishedWorker # rubocop:disable Scalability/IdempotentWorker
|
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
|
2020-03-02 13:07:42 -05:00
|
|
|
urgency :high
|
2019-10-30 11:14:17 -04:00
|
|
|
worker_resource_boundary :cpu
|
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)
|
2020-02-13 13:09:00 -05:00
|
|
|
ExpirePipelineCacheWorker.perform_async(build.pipeline_id) if build.pipeline.cacheable?
|
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
|
2019-09-13 09:26:31 -04:00
|
|
|
|
|
|
|
BuildFinishedWorker.prepend_if_ee('EE::BuildFinishedWorker')
|