Empty rebases should not generate a pipeline
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=330822) </details> <!--IssueSummary end--> <!--- Please read this! Before opening a new issue, make sure to search for keywords in the issues filtered by the "regression" or "bug" label: - https://gitlab.com/gitlab-org/gitlab/issues?label_name%5B%5D=regression - https://gitlab.com/gitlab-org/gitlab/issues?label_name%5B%5D=bug and verify the issue you're about to submit isn't a duplicate. ---> ### Summary <!-- Summarize the bug encountered concisely. --> When the merge request rebase REST API is used, every invocation done generates a new pipeline. A pipeline is generated even if the rebase itself was a no-operation (target had no new changes). Repeating the /rebase API keeps generating new pipelines, all for the same ref, which wastes resources. This is incorrect behavior as an empty push from the CLI, as comparison, does not generate a new pipeline. The API does provide a `skip_ci` option to explicitly skip the pipeline via a push option set internally, but the default behavior appears incorrect when the rebase does no real work/change. ### Steps to reproduce <!-- Describe how one can reproduce the issue - this is very important. Please use an ordered list. --> 1. Open an MR on any project with a pipeline 2. Run the PUT Rebase API on the MR repeatedly (4-5 times): https://docs.gitlab.com/ee/api/merge_requests.html#rebase-a-merge-request 3. Observe the MR's pipelines tab for duplicated, and un-cancelled pipelines ### Example Project <!-- If possible, please create an example project here on GitLab.com that exhibits the problematic behavior, and link to it here in the bug report. If you are using an older version of GitLab, this will also determine whether the bug is fixed in a more recent version. --> https://gitlab.com/gitlab-gold/hchouraria/rebase-redundant-pipeline/-/merge_requests/1/pipelines ### What is the current *bug* behavior? <!-- Describe what actually happens. --> Rebase with no change generates a pipeline. ### What is the expected *correct* behavior? <!-- Describe what you should see instead. --> Rebase with no change does not generate a pipeline. (Or,) New rebase generated pipelines must cancel previously running redundant pipelines, even if they are for the same ref. ### Relevant logs and/or screenshots <!-- Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's tough to read otherwise. --> https://gitlab.com/gitlab-gold/hchouraria/rebase-redundant-pipeline/-/merge_requests/1/pipelines ### Output of checks <!-- If you are reporting a bug on GitLab.com, write: This bug happens on GitLab.com --> This bug happens on GitLab.com #### Results of GitLab environment info <!-- Input any relevant GitLab environment information if needed. --> <details> <summary>Expand for output related to GitLab environment info</summary> <pre> (For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`) </pre> </details> #### Results of GitLab application Check <!-- Input any relevant GitLab application check information if needed. --> <details> <summary>Expand for output related to the GitLab application check</summary> <pre> (For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:check SANITIZE=true`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true`) (we will only investigate if the tests are passing) </pre> </details> ### Possible fixes <!-- If you can, link to the line of code that might be responsible for the problem. --> The CI run here is unconditional, unless entirely skipped: https://gitlab.com/gitlab-org/gitlab/blob/v13.11.0-ee/app/models/repository.rb#L1050-1068
issue