WIP: Create MR pipelines when branch pipeline is created (v1)
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
- Pipelines for branches/tags are created always
- Pipelines for merge requests are created only if
only/except: merge-requests
is specified - A merge request can have both branch/tag pipelines and MR pipelines
- A merge request can get a list of branch/tag pipelines
- A merge request can get a list of MR pipelines
- A pipeline knows whether it is a branch/tag pipeline or an MR pipeline
- An MR pipeline can get a list of merge requests
merge_requests
and ci_pipelines
tables
Persist many-to-many relationship between 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, throughmerge_request_pipelines
-
pipeline.merge_requests
returns associated merge requests, throughmerge_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, throughmerge_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.
ci_merge_request_pipelines
feature flag
We can disable MR pipelines creation via 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?
-
Changelog entry added, if necessary -
Documentation created/updated -
Tests added for this feature/bug -
Conforms to the code review guidelines -
Conforms to the merge request performance guidelines -
Conforms to the style guides -
Conforms to the database guides -
Link to e2e tests MR added if this MR has Requires e2e tests label. See the Test Planning Process.