From 4c8cb9bd0befff6a0e8127dbef6286ae7df72f76 Mon Sep 17 00:00:00 2001 From: Hordur Freyr Yngvason Date: Wed, 8 Oct 2025 12:34:38 -0400 Subject: [PATCH] Fix missing gitaly_context forward in BranchPushService In order to prevent "CI loops" with the job token push feature, we set a `glBuildId` in the Gitaly context whenever a push originates from a CI job, and forbid pipeline creation when this key is present. This was already working for branches and tags, but we missed forwarding this variable for merge request pipelines. See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/197418#note_2745993919 Changelog: fixed --- app/services/git/branch_push_service.rb | 2 +- spec/services/git/branch_push_service_spec.rb | 2 +- spec/services/git/process_ref_changes_service_spec.rb | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/services/git/branch_push_service.rb b/app/services/git/branch_push_service.rb index 464d79d99911ca..d8c88953ee9ca1 100644 --- a/app/services/git/branch_push_service.rb +++ b/app/services/git/branch_push_service.rb @@ -45,7 +45,7 @@ def enqueue_update_mrs oldrev, newrev, ref, - params.slice(:push_options).deep_stringify_keys + params.slice(:push_options, :gitaly_context).deep_stringify_keys ) end diff --git a/spec/services/git/branch_push_service_spec.rb b/spec/services/git/branch_push_service_spec.rb index 641e560487eedd..90a0355edc7052 100644 --- a/spec/services/git/branch_push_service_spec.rb +++ b/spec/services/git/branch_push_service_spec.rb @@ -146,7 +146,7 @@ it "when pushing a new branch for the first time" do expect(UpdateMergeRequestsWorker) .to receive(:perform_async) - .with(project.id, user.id, blankrev, newrev, ref, { 'push_options' => nil }) + .with(project.id, user.id, blankrev, newrev, ref, { 'push_options' => nil, 'gitaly_context' => nil }) .ordered subject diff --git a/spec/services/git/process_ref_changes_service_spec.rb b/spec/services/git/process_ref_changes_service_spec.rb index 05e24cc329a36e..0a7b1a1a40fef0 100644 --- a/spec/services/git/process_ref_changes_service_spec.rb +++ b/spec/services/git/process_ref_changes_service_spec.rb @@ -287,7 +287,7 @@ def multiple_changes(change, count) Gitlab::Git::SHA1_BLANK_SHA, '789012', "#{ref_prefix}/create1", - { 'push_options' => nil }).ordered + { 'gitaly_context' => nil, 'push_options' => nil }).ordered expect(UpdateMergeRequestsWorker).to receive(:perform_async).with( project.id, @@ -295,7 +295,7 @@ def multiple_changes(change, count) Gitlab::Git::SHA1_BLANK_SHA, '789013', "#{ref_prefix}/create2", - { 'push_options' => nil }).ordered + { 'gitaly_context' => nil, 'push_options' => nil }).ordered expect(UpdateMergeRequestsWorker).to receive(:perform_async).with( project.id, @@ -303,7 +303,7 @@ def multiple_changes(change, count) '789015', '789016', "#{ref_prefix}/changed1", - { 'push_options' => nil }).ordered + { 'gitaly_context' => nil, 'push_options' => nil }).ordered expect(UpdateMergeRequestsWorker).to receive(:perform_async).with( project.id, @@ -311,7 +311,7 @@ def multiple_changes(change, count) '789020', Gitlab::Git::SHA1_BLANK_SHA, "#{ref_prefix}/removed2", - { 'push_options' => nil }).ordered + { 'gitaly_context' => nil, 'push_options' => nil }).ordered subject.execute end -- GitLab