diff options
Diffstat (limited to 'app/workers/environments/stop_job_success_worker.rb')
-rw-r--r-- | app/workers/environments/stop_job_success_worker.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/app/workers/environments/stop_job_success_worker.rb b/app/workers/environments/stop_job_success_worker.rb new file mode 100644 index 00000000000..cc7d83512f3 --- /dev/null +++ b/app/workers/environments/stop_job_success_worker.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Environments + class StopJobSuccessWorker + include ApplicationWorker + + data_consistency :delayed + idempotent! + feature_category :continuous_delivery + + def perform(job_id, _params = {}) + Ci::Build.find_by_id(job_id).try do |build| + stop_environment(build) if build.stops_environment? && build.stop_action_successful? + end + end + + private + + def stop_environment(build) + build.persisted_environment.fire_state_event(:stop_complete) + end + end +end |