Skip to content

WIP: Create MR pipelines when branch pipeline is created (v1)

Shinya Maeda requested to merge mr-pipelines into master

What does this MR do?

This is an MR for Deliverable issue in %11.6.

You can get the basic idea of MR pipelines in https://gitlab.com/gitlab-org/gitlab-ce/issues/15310's description.

Here, in this MR description, we'll explain its technical details.

Rules of thumb

  1. Pipelines for branches/tags are created always
  2. Pipelines for merge requests are created only if only/except: merge-requests is specified
  3. A merge request can have both branch/tag pipelines and MR pipelines
  4. A merge request can get a list of branch/tag pipelines
  5. A merge request can get a list of MR pipelines
  6. A pipeline knows whether it is a branch/tag pipeline or an MR pipeline
  7. An MR pipeline can get a list of merge requests

Persist many-to-many relationship between merge_requests and ci_pipelines tables

In this MR, we introduce merge_request_pipelines table. This table is for persisting many-to-many relationship between merge_requests and ci_pipelines tables.

With that, we can query data in an efficient way.

  • merge_request.pipelines returns associated MR pipelines, through merge_request_pipelines
  • pipeline.merge_requests returns associated merge requests, through merge_request_pipelines
  • merge_request.all_pipelines returns associated branch/MR pipelines with SHAs and source ref
  • pipeline.merge_requests_as_head_pipeline returns associated merge requests, through merge_requests.head_pipeline_id

Create a MR pipeline after a branch pipeline creation

This is a boring solution, but very explicit way for clarifying when/where we create MR pipelines.

Basically, all Ci::CreatePipelineService execution is followed by Ci::CreateMergeRequestPipelinesService. This CreateMergeRequestPipelinesService does search related merge requests from a given SHA, and iterate CreatePipelineService execution.

We can disable MR pipelines creation via ci_merge_request_pipelines feature flag

We can easily disable the additional MR pipeline creation by executing Feature.disable('ci_merge_request_pipelines'). It will immidiately stop new MR pipeline creation and there are no harm.

What are the relevant issue numbers?

Related https://gitlab.com/gitlab-org/gitlab-ce/issues/15310

Does this MR meet the acceptance criteria?

Edited by Shinya Maeda

Merge request reports

Loading