gitlab-org--gitlab-foss/app/workers/build_success_worker.rb

26 lines
685 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class BuildSuccessWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
include PipelineQueue
2017-11-28 11:16:50 -05:00
queue_namespace :pipeline_processing
urgency :high
# rubocop: disable CodeReuse/ActiveRecord
def perform(build_id)
Ci::Build.find_by(id: build_id).try do |build|
stop_environment(build) if build.stops_environment?
end
end
# rubocop: enable CodeReuse/ActiveRecord
private
##
# 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)
end
end