2018-06-27 07:23:28 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-13 10:58:25 +00:00
|
|
|
class BuildSuccessWorker
|
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-13 10:58:25 +00:00
|
|
|
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2016-10-13 10:58:25 +00:00
|
|
|
def perform(build_id)
|
|
|
|
Ci::Build.find_by(id: build_id).try do |build|
|
2018-11-06 01:52:55 +00:00
|
|
|
stop_environment(build) if build.stops_environment?
|
2016-10-13 10:58:25 +00:00
|
|
|
end
|
|
|
|
end
|
2018-08-27 15:31:01 +00:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2016-10-13 10:58:25 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-11-06 01:52:55 +00:00
|
|
|
##
|
|
|
|
# TODO: This should be processed in DeploymentSuccessWorker once we started storing `action` value in `deployments` records
|
|
|
|
def stop_environment(build)
|
2018-11-06 02:45:39 +00:00
|
|
|
build.persisted_environment.fire_state_event(:stop)
|
2018-11-06 01:52:55 +00:00
|
|
|
end
|
2016-10-13 10:58:25 +00:00
|
|
|
end
|