diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 23119c5ed61964354dca688e7ef2b7126952c154..87475119b23766e41d94996669e36c68002c7aa1 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -83,8 +83,7 @@ module Ci
 
       after_transition any => [:success, :failed, :canceled] do |build|
         build.run_after_commit do
-          BuildCoverageWorker.perform_async(id)
-          BuildHooksWorker.perform_async(id)
+          BuildFinishedWorker.perform_async(id)
         end
       end
 
diff --git a/app/workers/build_finished_worker.rb b/app/workers/build_finished_worker.rb
new file mode 100644
index 0000000000000000000000000000000000000000..f1267ab92fcfe0c64d3df185d1bd65186c50e2ef
--- /dev/null
+++ b/app/workers/build_finished_worker.rb
@@ -0,0 +1,12 @@
+class BuildFinishedWorker
+  include Sidekiq::Worker
+
+  def perform(build_id)
+    Ci::Build.find_by(id: build_id).try do |build|
+      build.with_lock do
+        BuildCoverageWorker.new.perform(build.id)
+        BuildHooksWorker.new.perform(build.id)
+      end
+    end
+  end
+end
diff --git a/spec/workers/build_finished_worker_spec.rb b/spec/workers/build_finished_worker_spec.rb
new file mode 100644
index 0000000000000000000000000000000000000000..2868167c7d41917c39172a051f777c3076faaa63
--- /dev/null
+++ b/spec/workers/build_finished_worker_spec.rb
@@ -0,0 +1,30 @@
+require 'spec_helper'
+
+describe BuildFinishedWorker do
+  describe '#perform' do
+    context 'when build exists' do
+      let(:build) { create(:ci_build) }
+
+      it 'calculates coverage and calls hooks' do
+        expect(BuildCoverageWorker)
+          .to receive(:new).ordered.and_call_original
+        expect(BuildHooksWorker)
+          .to receive(:new).ordered.and_call_original
+
+        expect_any_instance_of(BuildCoverageWorker)
+          .to receive(:perform)
+        expect_any_instance_of(BuildHooksWorker)
+          .to receive(:perform)
+
+        described_class.new.perform(build.id)
+      end
+    end
+
+    context 'when build does not exist' do
+      it 'does not raise exception' do
+        expect { described_class.new.perform(123) }
+          .not_to raise_error
+      end
+    end
+  end
+end