2018-06-27 07:23:28 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-02-19 18:09:10 +00:00
|
|
|
class BuildSuccessWorker # rubocop:disable Scalability/IdempotentWorker
|
2017-11-28 16:08:30 +00:00
|
|
|
include ApplicationWorker
|
2021-04-30 18:10:09 +00:00
|
|
|
|
2021-07-21 12:09:35 +00:00
|
|
|
data_consistency :always
|
|
|
|
|
2021-04-30 18:10:09 +00:00
|
|
|
sidekiq_options retry: 3
|
2017-08-21 12:16:51 +00:00
|
|
|
include PipelineQueue
|
|
|
|
|
2017-11-28 16:16:50 +00:00
|
|
|
queue_namespace :pipeline_processing
|
2020-03-02 18:07:42 +00:00
|
|
|
urgency :high
|
2016-10-13 10:58:25 +00:00
|
|
|
|
|
|
|
def perform(build_id)
|
2021-11-10 15:13:21 +00:00
|
|
|
Ci::Build.find_by_id(build_id).try do |build|
|
2022-05-24 12:09:04 +00:00
|
|
|
stop_environment(build) if build.stops_environment? && build.stop_action_successful?
|
2016-10-13 10:58:25 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-11-06 01:52:55 +00:00
|
|
|
def stop_environment(build)
|
2022-05-24 12:09:04 +00:00
|
|
|
build.persisted_environment.fire_state_event(:stop_complete)
|
2018-11-06 01:52:55 +00:00
|
|
|
end
|
2016-10-13 10:58:25 +00:00
|
|
|
end
|