Backend: Ensure no pipeline runs when rebasing without triggering CI

Release notes

Problem to solve

When we skip CI for a rebase we skip creating a pipeline for branch but a merge request pipeline creation is still attempted. We would need to verify that. this was observed in !76056 (comment 756816723)

Not having a head pipeline for the merge request could block merging unless the user has "pipelines must succeed" setting disabled.

User experience goal

When we are telling the user that the pipeline would not run for the rebase, we should make sure that it doesn't.

Proposal

#118825 (closed) attempts at bringing the API based feature to skip CI for rebase to the UI, but the behaviour on the backend need to be fixed to skip the pipeline for merge request(detached) from running altogether.

from the original MR comment

To effectively skip also the merge request pipeline we would need to pass push options down to MergeRequests::CreatePipelineService from Git::BranchPushService. This should then skip also the merge request pipeline. This though, may be better be a separate issue where we change the background behavior, then in this MR we use the API for the frontend. WDYT?

flowchart TD

rebase[Rebase the MR with `ci.skip` push option] --> push[Push changes to remote]
push --> receive[PostReceive worker - with push options sent through]
receive --> Git::BranchPushService
Git::BranchPushService -- push options not yet forwarded --> UpdateMergeRequestsWorker --> MergeRequests::RefreshService --> MergeRequests::CreatePipelineService -- no push options --> Ci::CreatePipelineService --> bug[pipeline not skipped]
Git::BranchPushService -- push options already forwarded --> Git::BranchHooksService --> Git::BaseHooksService -- with push options --> Ci::CreatePipelineService --> skipped[pipeline skipped]

Links / references

!76056 (comment 756816723)

This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.

Edited by Fabio Pitino