Extend CI_PIPELINE_SOURCE values to distinguish between a git push and a rebase

Release notes

Problem to solve

As a devops integration designer, I want to specify workflows based upon whether a git operation is a rebase, or a push, so that I can avoid unnecessary duplicate pipeline runs when rebasing code from a parent branch. This will avoid delaying my team's work, particularly for long-running jobs.

Intended users

User experience goal

The user should be able to distinguish between regular git pushes initiated through git operations, or rebases executed from an open Merge Request, and then write custom workflows based upon this fact.

Proposal

Similar to when a new MR is created, the value of CI_PIPELINE_SOURCE could be changed from push to some other value (such as rebase) when the Rebase button on an MR is pushed. One could then set up a workflow rule to avoid expensive and slow pipeline stages when they are not wanted:

workflow:
  rules:
    - if: '$CI_PIPELINE_SOURCE = rebase'
      when: never
    - if: '$CI_DEFAULT_BRANCH'

Further details

Customer has a project with very expensive builds — they take a couple of hours each. They would like to squash commits into the main branch without merge commits, and allow concurrent MRs to run. They are not worried about cross-MR conflicts — if the code passes on its branch, then they are happy to merge it.

In the absence of a Squash-and-Merge ability in the MR, it would help if there was a way to tell that the operation triggering a pipeline was because the Rebase button has been pressed: then a workflow could be coded to take a different course (different, less expensive job, or no job) to suit the customer's custom work flows.

Permissions and Security

Documentation

Availability & Testing

Available Tier

What does success look like, and how can we measure that?

What is the type of buyer?

Is this a cross-stage feature?

This may have impacts on:

  • Verify stage
    • Pipeline Authoring group
    • Continuous Integration group
  • Create stage
    • Code Review group (merge requests)
    • Source Code group (gitlab-shell)
    • Gitaly group

Links / references

  • #1511 is an issue to implement "Squash-and-Merge" in a manner similar to GitHub, such that this is a single commit rather than two. This would also avoid re-running pipelines unnecisarily
Edited by Mike Lockhart | GitLab