diff --git a/app/services/ci/create_commit_status_service.rb b/app/services/ci/create_commit_status_service.rb
index de3e7b3f7ffae78cc9b645f7cb184ad2ad0c8d42..24a9130e7acf0c862fd65e057b677a1d8a17ea64 100644
--- a/app/services/ci/create_commit_status_service.rb
+++ b/app/services/ci/create_commit_status_service.rb
@@ -36,7 +36,6 @@ def unsafe_execute
 
       return bad_request(response.message) if response.error?
 
-      update_merge_request_head_pipeline
       response
     end
 
@@ -73,6 +72,10 @@ def create_pipeline
       ).tap do |new_pipeline|
         new_pipeline.ensure_project_iid!
         new_pipeline.save!
+
+        Gitlab::EventStore.publish(
+          Ci::PipelineCreatedEvent.new(data: { pipeline_id: new_pipeline.id })
+        )
       end
     end
 
@@ -106,14 +109,6 @@ def add_or_update_external_job
       end
     end
 
-    def update_merge_request_head_pipeline
-      return unless pipeline.latest?
-
-      ::MergeRequest
-        .from_project(project).from_source_branches(ref)
-        .update_all(head_pipeline_id: pipeline.id)
-    end
-
     def apply_job_state!(job)
       case params[:state]
       when 'pending'
diff --git a/spec/requests/api/commit_statuses_spec.rb b/spec/requests/api/commit_statuses_spec.rb
index 97e4f8f16b4503836628f315894ceaa1c7faad26..24dc414710dc39d8dba11fe45fd1e14507f364ac 100644
--- a/spec/requests/api/commit_statuses_spec.rb
+++ b/spec/requests/api/commit_statuses_spec.rb
@@ -293,9 +293,11 @@ def create_status(commit, opts = {})
           end
 
           context 'when merge request exists for given branch' do
-            let!(:merge_request) { create(:merge_request, source_project: project, source_branch: 'master', target_branch: 'develop') }
+            let!(:merge_request) do
+              create(:merge_request, source_project: project, head_pipeline_id: nil)
+            end
 
-            it 'sets head pipeline' do
+            it 'sets head pipeline', :sidekiq_inline do
               subject
 
               expect(response).to have_gitlab_http_status(:created)
diff --git a/spec/services/ci/create_commit_status_service_spec.rb b/spec/services/ci/create_commit_status_service_spec.rb
index cbdb681afe31b5a4f85caef70f7e820e25085119..67989347d4e0d9002da4e37d359d19b4a2473dda 100644
--- a/spec/services/ci/create_commit_status_service_spec.rb
+++ b/spec/services/ci/create_commit_status_service_spec.rb
@@ -112,10 +112,10 @@
 
       context 'when merge request exists for given branch' do
         let!(:merge_request) do
-          create(:merge_request, source_project: project, source_branch: 'master', target_branch: 'develop')
+          create(:merge_request, source_project: project, head_pipeline: nil)
         end
 
-        it 'sets head pipeline' do
+        it 'sets head pipeline', :sidekiq_inline do
           expect { response }
             .to change { ::Ci::Pipeline.count }.by(1)
             .and change { ::Ci::Stage.count }.by(1)
@@ -124,6 +124,34 @@
           expect(response).to be_success
           expect(merge_request.reload.head_pipeline).not_to be_nil
         end
+
+        context 'when the MR has a branch head pipeline' do
+          let!(:merge_request) do
+            create(:merge_request, :with_head_pipeline, source_project: project)
+          end
+
+          it 'adds the status to the existing pipeline' do
+            expect { response }.not_to change { ::Ci::Pipeline.count }
+            expect(response.payload[:job].pipeline_id).to eq(merge_request.head_pipeline_id)
+          end
+        end
+
+        context 'when the MR has a merged result head pipeline' do
+          let!(:merge_request) do
+            create(:merge_request, source_project: project, head_pipeline: head_pipeline)
+          end
+
+          let(:head_pipeline) { create(:ci_pipeline, :merged_result_pipeline) }
+
+          it 'creates a new branch pipeline but does not change the head pipeline' do
+            expect { response }
+              .to change { ::Ci::Pipeline.count }.by(1)
+              .and change { ::Ci::Stage.count }.by(1)
+              .and change { ::CommitStatus.count }.by(1)
+
+            expect(merge_request.reload.head_pipeline_id).to eq(head_pipeline.id)
+          end
+        end
       end
     end