2018-06-27 03:23:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-02-19 13:09:10 -05:00
|
|
|
class BuildSuccessWorker # rubocop:disable Scalability/IdempotentWorker
|
2017-11-28 11:08:30 -05:00
|
|
|
include ApplicationWorker
|
2021-04-30 14:10:09 -04:00
|
|
|
|
|
|
|
sidekiq_options retry: 3
|
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
|
2016-10-13 06:58:25 -04:00
|
|
|
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2016-10-13 06:58:25 -04:00
|
|
|
def perform(build_id)
|
|
|
|
Ci::Build.find_by(id: build_id).try do |build|
|
2018-11-05 20:52:55 -05:00
|
|
|
stop_environment(build) if build.stops_environment?
|
2016-10-13 06:58:25 -04:00
|
|
|
end
|
|
|
|
end
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2016-10-13 06:58:25 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-11-05 20:52:55 -05:00
|
|
|
##
|
|
|
|
# TODO: This should be processed in DeploymentSuccessWorker once we started storing `action` value in `deployments` records
|
|
|
|
def stop_environment(build)
|
2018-11-05 21:45:39 -05:00
|
|
|
build.persisted_environment.fire_state_event(:stop)
|
2018-11-05 20:52:55 -05:00
|
|
|
end
|
2016-10-13 06:58:25 -04:00
|
|
|
end
|