Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-06-29 21:07:04 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-06-29 21:07:04 +0300
commitbc0c5df2f15523e8c4a57682b149526f0cf55b9c (patch)
tree5264741513c3d10e1589e9566243ea6202b69e63 /doc/ci/pipelines
parentcbafce7e89a8761c0c8062392803346f42f489fc (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'doc/ci/pipelines')
-rw-r--r--doc/ci/pipelines/img/merge_train_cancel_v12_0.pngbin0 -> 7654 bytes
-rw-r--r--doc/ci/pipelines/img/merge_train_failure.pngbin0 -> 23899 bytes
-rw-r--r--doc/ci/pipelines/img/merge_train_immediate_merge_v12_6.pngbin0 -> 18607 bytes
-rw-r--r--doc/ci/pipelines/img/merge_train_position_v12_0.pngbin0 -> 6152 bytes
-rw-r--r--doc/ci/pipelines/img/merge_train_start_v12_0.pngbin0 -> 3548 bytes
-rw-r--r--doc/ci/pipelines/img/merge_train_start_when_pipeline_succeeds_v12_0.pngbin0 -> 4337 bytes
-rw-r--r--doc/ci/pipelines/img/merged_result_pipeline.pngbin0 -> 7374 bytes
-rw-r--r--doc/ci/pipelines/img/pipeline-fork_v13_7.pngbin0 -> 15697 bytes
-rw-r--r--doc/ci/pipelines/index.md10
-rw-r--r--doc/ci/pipelines/merge_request_pipelines.md215
-rw-r--r--doc/ci/pipelines/merge_trains.md236
-rw-r--r--doc/ci/pipelines/pipelines_for_merged_results.md135
12 files changed, 591 insertions, 5 deletions
diff --git a/doc/ci/pipelines/img/merge_train_cancel_v12_0.png b/doc/ci/pipelines/img/merge_train_cancel_v12_0.png
new file mode 100644
index 00000000000..d7720ac1143
--- /dev/null
+++ b/doc/ci/pipelines/img/merge_train_cancel_v12_0.png
Binary files differ
diff --git a/doc/ci/pipelines/img/merge_train_failure.png b/doc/ci/pipelines/img/merge_train_failure.png
new file mode 100644
index 00000000000..8a795fff432
--- /dev/null
+++ b/doc/ci/pipelines/img/merge_train_failure.png
Binary files differ
diff --git a/doc/ci/pipelines/img/merge_train_immediate_merge_v12_6.png b/doc/ci/pipelines/img/merge_train_immediate_merge_v12_6.png
new file mode 100644
index 00000000000..7b903716a3d
--- /dev/null
+++ b/doc/ci/pipelines/img/merge_train_immediate_merge_v12_6.png
Binary files differ
diff --git a/doc/ci/pipelines/img/merge_train_position_v12_0.png b/doc/ci/pipelines/img/merge_train_position_v12_0.png
new file mode 100644
index 00000000000..ec4b157d428
--- /dev/null
+++ b/doc/ci/pipelines/img/merge_train_position_v12_0.png
Binary files differ
diff --git a/doc/ci/pipelines/img/merge_train_start_v12_0.png b/doc/ci/pipelines/img/merge_train_start_v12_0.png
new file mode 100644
index 00000000000..a4d0c8cf0e6
--- /dev/null
+++ b/doc/ci/pipelines/img/merge_train_start_v12_0.png
Binary files differ
diff --git a/doc/ci/pipelines/img/merge_train_start_when_pipeline_succeeds_v12_0.png b/doc/ci/pipelines/img/merge_train_start_when_pipeline_succeeds_v12_0.png
new file mode 100644
index 00000000000..45762b8e85e
--- /dev/null
+++ b/doc/ci/pipelines/img/merge_train_start_when_pipeline_succeeds_v12_0.png
Binary files differ
diff --git a/doc/ci/pipelines/img/merged_result_pipeline.png b/doc/ci/pipelines/img/merged_result_pipeline.png
new file mode 100644
index 00000000000..2584cd4d38d
--- /dev/null
+++ b/doc/ci/pipelines/img/merged_result_pipeline.png
Binary files differ
diff --git a/doc/ci/pipelines/img/pipeline-fork_v13_7.png b/doc/ci/pipelines/img/pipeline-fork_v13_7.png
new file mode 100644
index 00000000000..eb44290aa66
--- /dev/null
+++ b/doc/ci/pipelines/img/pipeline-fork_v13_7.png
Binary files differ
diff --git a/doc/ci/pipelines/index.md b/doc/ci/pipelines/index.md
index 5041b56bba7..621ad4a60d9 100644
--- a/doc/ci/pipelines/index.md
+++ b/doc/ci/pipelines/index.md
@@ -54,12 +54,12 @@ Pipelines can be configured in many different ways:
- [Parent-Child pipelines](../parent_child_pipelines.md) break down complex pipelines
into one parent pipeline that can trigger multiple child sub-pipelines, which all
run in the same project and with the same SHA.
-- [Pipelines for Merge Requests](../merge_request_pipelines/index.md) run for merge
+- [Pipelines for Merge Requests](../pipelines/merge_request_pipelines.md) run for merge
requests only (rather than for every commit).
-- [Pipelines for Merged Results](../merge_request_pipelines/pipelines_for_merged_results/index.md)
+- [Pipelines for Merged Results](../pipelines/pipelines_for_merged_results.md)
are merge request pipelines that act as though the changes from the source branch have
already been merged into the target branch.
-- [Merge Trains](../merge_request_pipelines/pipelines_for_merged_results/merge_trains/index.md)
+- [Merge Trains](../pipelines/merge_trains.md)
use pipelines for merged results to queue merges one after the other.
## Configure a pipeline
@@ -89,13 +89,13 @@ This table lists the refspecs injected for each pipeline type:
|--------------- |---------------------------------------- |
| Pipeline for Branches | `+<sha>:refs/pipelines/<id>` and `+refs/heads/<name>:refs/remotes/origin/<name>` |
| pipeline for Tags | `+<sha>:refs/pipelines/<id>` and `+refs/tags/<name>:refs/tags/<name>` |
-| [Pipeline for Merge Requests](../merge_request_pipelines/index.md) | `+<sha>:refs/pipelines/<id>` |
+| [Pipeline for Merge Requests](../pipelines/merge_request_pipelines.md) | `+<sha>:refs/pipelines/<id>` |
The refs `refs/heads/<name>` and `refs/tags/<name>` exist in your
project repository. GitLab generates the special ref `refs/pipelines/<id>` during a
running pipeline job. This ref can be created even after the associated branch or tag has been
deleted. It's therefore useful in some features such as [automatically stopping an environment](../environments/index.md#stopping-an-environment),
-and [merge trains](../merge_request_pipelines/pipelines_for_merged_results/merge_trains/index.md)
+and [merge trains](../pipelines/merge_trains.md)
that might run pipelines after branch deletion.
### View pipelines
diff --git a/doc/ci/pipelines/merge_request_pipelines.md b/doc/ci/pipelines/merge_request_pipelines.md
new file mode 100644
index 00000000000..29c12551f12
--- /dev/null
+++ b/doc/ci/pipelines/merge_request_pipelines.md
@@ -0,0 +1,215 @@
+---
+stage: Verify
+group: Pipeline Execution
+info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
+type: reference, index
+last_update: 2019-07-03
+---
+
+# Pipelines for merge requests **(FREE)**
+
+> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/15310) in GitLab 11.6.
+
+In a [basic configuration](pipeline_architectures.md#basic-pipelines), GitLab runs a pipeline each time
+changes are pushed to a branch.
+
+If you want the pipeline to run jobs **only** on commits associated with a merge request,
+you can use *pipelines for merge requests*.
+
+In the UI, these pipelines are labeled as `detached`. Otherwise, these pipelines are the same
+as other pipelines.
+
+Pipelines for merge requests can run when you:
+
+- Create a new merge request.
+- Commit changes to the source branch for the merge request.
+- Select the **Run pipeline** button from the **Pipelines** tab in the merge request.
+
+If you use this feature with [merge when pipeline succeeds](../../user/project/merge_requests/merge_when_pipeline_succeeds.md),
+pipelines for merge requests take precedence over other pipelines.
+
+## Prerequisites
+
+To enable pipelines for merge requests:
+
+- Your repository must be a GitLab repository, not an
+ [external repository](../ci_cd_for_external_repos/index.md).
+- You must have the Developer [role](../../user/permissions.md)
+ to run a pipeline for merge requests.
+
+## Configure pipelines for merge requests
+
+To configure pipelines for merge requests, you must configure your [CI/CD configuration file](../yaml/index.md).
+To do this, you can use [`rules`](#use-rules-to-run-pipelines-for-merge-requests) or [`only/except`](#use-only-or-except-to-run-pipelines-for-merge-requests).
+
+### Use `rules` to run pipelines for merge requests
+
+GitLab recommends that you use the `rules` keyword, which is available in
+[`workflow:rules` templates](../yaml/index.md#workflowrules-templates).
+
+### Use `only` or `except` to run pipelines for merge requests
+
+You can use the `only/except` keywords. However, with this method, you must specify `only: - merge_requests` for each job.
+
+In the following example, the pipeline contains a `test` job that is configured to run on merge requests.
+The `build` and `deploy` jobs don't have the `only: - merge_requests` keyword,
+so they don't run on merge requests.
+
+```yaml
+build:
+ stage: build
+ script: ./build
+ only:
+ - main
+
+test:
+ stage: test
+ script: ./test
+ only:
+ - merge_requests
+
+deploy:
+ stage: deploy
+ script: ./deploy
+ only:
+ - main
+```
+
+#### Exclude specific jobs
+
+When you use `only: [merge_requests]`, only jobs with
+that keyword are run in the context of a merge request. No other jobs run.
+
+However, you can invert this behavior and have all of your jobs run except
+for one or two. For example, you might have a pipeline with jobs `A`, `B`, and `C`, and you want:
+
+- All pipelines to always run `A` and `B`.
+- `C` to run only for merge requests.
+
+To achieve this outcome, configure your `.gitlab-ci.yml` file as follows:
+
+```yaml
+.only-default: &only-default
+ only:
+ - main
+ - merge_requests
+ - tags
+
+A:
+ <<: *only-default
+ script:
+ - ...
+
+B:
+ <<: *only-default
+ script:
+ - ...
+
+C:
+ script:
+ - ...
+ only:
+ - merge_requests
+```
+
+- `A` and `B` always run, because they get the `only:` rule to execute in all cases.
+- `C` only runs for merge requests. It doesn't run for any pipeline
+ except a merge request pipeline.
+
+In this example, you don't have to add the `only:` rule to all of your jobs to make
+them always run. You can use this format to set up a Review App, which helps to
+save resources.
+
+#### Exclude specific branches
+
+Branch refs use this format: `refs/heads/my-feature-branch`.
+Merge request refs use this format: `refs/merge-requests/:iid/head`.
+
+Because of this difference, the following configuration does not work as expected:
+
+```yaml
+# Does not exclude a branch named "docs-my-fix"!
+test:
+ only: [merge_requests]
+ except: [/^docs-/]
+```
+
+Instead, use the
+[`$CI_COMMIT_REF_NAME` predefined environment
+variable](../variables/predefined_variables.md) in
+combination with
+[`only:variables`](../yaml/index.md#onlyvariables--exceptvariables) to
+accomplish this behavior:
+
+```yaml
+test:
+ only: [merge_requests]
+ except:
+ variables:
+ - $CI_COMMIT_REF_NAME =~ /^docs-/
+```
+
+## Run pipelines in the parent project for merge requests from a forked project **(PREMIUM)**
+
+> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/217451) in GitLab 13.3.
+> - [Moved](https://about.gitlab.com/blog/2021/01/26/new-gitlab-product-subscription-model/) to GitLab Premium in 13.9.
+
+By default, external contributors who work in forks can't create pipelines in the
+parent project. When a merge request that comes from a fork triggers a pipeline:
+
+- The pipeline is created and runs in the fork (source) project, not the parent (target) project.
+- The pipeline uses the fork project's CI/CD configuration and resources.
+
+If a pipeline runs in a fork, a **fork** badge appears for the pipeline in the merge request.
+
+![Pipeline ran in fork](img/pipeline-fork_v13_7.png)
+
+Sometimes parent project members want the pipeline to run in the parent
+project. They may want to ensure that the post-merge pipeline passes in the parent project.
+For example, a fork project could try to use a corrupted runner that doesn't execute
+test scripts properly, but reports a passed pipeline. Reviewers in the parent project
+could mistakenly trust the merge request because it passed a faked pipeline.
+
+Parent project members with at least the [Developer role](../../user/permissions.md)
+can create pipelines in the parent project for merge requests
+from a forked project. In the merge request, go to the **Pipelines** tab and select
+**Run pipeline**.
+
+WARNING:
+Fork merge requests can contain malicious code that tries to steal secrets in the
+parent project when the pipeline runs, even before merge. As a reviewer, you must carefully
+check the changes in the merge request before triggering the pipeline. GitLab shows
+a warning that you must accept before you can trigger the pipeline.
+
+## Predefined variables available for pipelines for merge requests
+
+When you use pipelines for merge requests, [additional predefined variables](../variables/predefined_variables.md#predefined-variables-for-merge-request-pipelines) are available to the CI/CD jobs.
+These variables contain information from the associated merge request, so that you can
+integrate your job with the [GitLab Merge Request API](../../api/merge_requests.md).
+
+## Troubleshooting
+
+### Two pipelines created when pushing to a merge request
+
+If you are experiencing duplicated pipelines when using `rules`, take a look at
+the [important differences between `rules` and `only`/`except`](../jobs/job_control.md#avoid-duplicate-pipelines),
+which helps you get your starting configuration correct.
+
+If you are seeing two pipelines when using `only/except`, please see the caveats
+related to using `only/except` above (or, consider moving to `rules`).
+
+In [GitLab 13.7](https://gitlab.com/gitlab-org/gitlab/-/issues/201845) and later,
+you can add `workflow:rules` to [switch from branch pipelines to merge request pipelines](../yaml/index.md#switch-between-branch-pipelines-and-merge-request-pipelines).
+After a merge request is open on the branch, the pipeline switches to a merge request pipeline.
+
+### Two pipelines created when pushing an invalid CI configuration file
+
+Pushing to a branch with an invalid CI configuration file can trigger
+the creation of two types of failed pipelines. One pipeline is a failed merge request
+pipeline, and the other is a failed branch pipeline, but both are caused by the same
+invalid configuration.
+
+## Related topics
+
+- [Pipelines for merged results](pipelines_for_merged_results.md).
+- [Merge trains](merge_trains.md).
diff --git a/doc/ci/pipelines/merge_trains.md b/doc/ci/pipelines/merge_trains.md
new file mode 100644
index 00000000000..3e6ad071d7e
--- /dev/null
+++ b/doc/ci/pipelines/merge_trains.md
@@ -0,0 +1,236 @@
+---
+stage: Verify
+group: Pipeline Execution
+info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
+type: reference
+last_update: 2019-07-03
+---
+
+# Merge Trains **(PREMIUM)**
+
+> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/9186) in [GitLab Premium](https://about.gitlab.com/pricing/) 12.0.
+> - [Squash and merge](../../user/project/merge_requests/squash_and_merge.md) support [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/13001) in [GitLab Premium](https://about.gitlab.com/pricing/) 12.6.
+
+For more information about why you might want to use Merge Trains, read [How merge trains keep your master green](https://about.gitlab.com/blog/2020/01/30/all-aboard-merge-trains/).
+
+When [pipelines for merged results](pipelines_for_merged_results.md) are
+enabled, the pipeline jobs run as if the changes from your source branch have already
+been merged into the target branch.
+
+However, the target branch may be changing rapidly. When you're ready to merge,
+if you haven't run the pipeline in a while, the target branch may have already changed.
+Merging now could introduce breaking changes.
+
+*Merge trains* can prevent this from happening. A merge train is a queued list of merge
+requests, each waiting to be merged into the target branch.
+
+Many merge requests can be added to the train. Each merge request runs its own merged results pipeline,
+which includes the changes from all of the other merge requests in *front* of it on the train.
+All the pipelines run in parallel, to save time.
+
+If the pipeline for a merge request fails, the breaking changes are not merged, and the target
+branch is unaffected. The merge request is removed from the train, and all pipelines behind it restart.
+
+If the pipeline for the merge request at the front of the train completes successfully,
+the changes are merged into the target branch, and the other pipelines continue to
+run.
+
+To add a merge request to a merge train, you need [permissions](../../user/permissions.md) to push to the target branch.
+
+Each merge train can run a maximum of **twenty** pipelines in parallel.
+If more than twenty merge requests are added to the merge train, the merge requests
+are queued until a slot in the merge train is free. There is no limit to the
+number of merge requests that can be queued.
+
+## Merge train example
+
+Three merge requests (`A`, `B` and `C`) are added to a merge train in order, which
+creates three merged results pipelines that run in parallel:
+
+1. The first pipeline runs on the changes from `A` combined with the target branch.
+1. The second pipeline runs on the changes from `A` and `B` combined with the target branch.
+1. The third pipeline runs on the changes from `A`, `B`, and `C` combined with the target branch.
+
+If the pipeline for `B` fails, it is removed from the train. The pipeline for
+`C` restarts with the `A` and `C` changes, but without the `B` changes.
+
+If `A` then completes successfully, it merges into the target branch, and `C` continues
+to run. If more merge requests are added to the train, they now include the `A`
+changes that are included in the target branch, and the `C` changes that are from
+the merge request already in the train.
+
+Read more about [how merge trains keep your master green](https://about.gitlab.com/blog/2020/01/30/all-aboard-merge-trains/).
+
+<i class="fa fa-youtube-play youtube" aria-hidden="true"></i>
+Watch this video for a demonstration on [how parallel execution
+of Merge Trains can prevent commits from breaking the default
+branch](https://www.youtube.com/watch?v=D4qCqXgZkHQ).
+
+## Prerequisites
+
+To enable merge trains:
+
+- You must have the [Maintainer role](../../user/permissions.md).
+- You must be using [GitLab Runner](https://gitlab.com/gitlab-org/gitlab-runner) 11.9 or later.
+- In GitLab 13.0 and later, you need [Redis](https://redis.io/) 5.0 or later.
+- Your repository must be a GitLab repository, not an
+ [external repository](../ci_cd_for_external_repos/index.md).
+
+## Enable merge trains
+
+To enable merge trains for your project:
+
+1. If you are on a self-managed GitLab instance, ensure the [feature flag](#merge-trains-feature-flag) is set correctly.
+1. [Configure your CI/CD configuration file](merge_request_pipelines.md#configure-pipelines-for-merge-requests)
+ so that the pipeline or individual jobs run for merge requests.
+1. Visit your project's **Settings > General** and expand **Merge requests**.
+1. In the **Merge method** section, verify that **Merge commit** is selected.
+ You cannot use **Merge commit with semi-linear history** or **Fast-forward merge** with merge trains.
+1. In the **Merge options** section, select **Enable merged results pipelines.** (if not already selected) and **Enable merge trains.**
+1. Click **Save changes**
+
+In GitLab 13.5 and earlier, there is only one checkbox, named
+**Enable merge trains and pipelines for merged results**.
+
+WARNING:
+If you select the check box but don't configure your CI/CD to use
+pipelines for merge requests, your merge requests may become stuck in an
+unresolved state or your pipelines may be dropped.
+
+## Start a merge train
+
+To start a merge train:
+
+1. Visit a merge request.
+1. Click the **Start merge train** button.
+
+![Start merge train](img/merge_train_start_v12_0.png)
+
+Other merge requests can now be added to the train.
+
+## Add a merge request to a merge train
+
+To add a merge request to a merge train:
+
+1. Visit a merge request.
+1. Click the **Add to merge train** button.
+
+If pipelines are already running for the merge request, you cannot add the merge request
+to the train. Instead, you can schedule to add the merge request to a merge train **when the latest
+pipeline succeeds**.
+
+![Add to merge train when pipeline succeeds](img/merge_train_start_when_pipeline_succeeds_v12_0.png)
+
+## Remove a merge request from a merge train
+
+1. Visit a merge request.
+1. Click the **Remove from merge train** button.
+
+![Cancel merge train](img/merge_train_cancel_v12_0.png)
+
+If you want to add the merge request to a merge train again later, you can.
+
+## View a merge request's current position on the merge train
+
+After a merge request has been added to the merge train, the merge request's
+current position is displayed under the pipeline widget:
+
+![Merge train position indicator](img/merge_train_position_v12_0.png)
+
+## Immediately merge a merge request with a merge train
+
+If you have a high-priority merge request (for example, a critical patch) that must
+be merged urgently, you can bypass the merge train by using the **Merge Immediately** option.
+This is the fastest option to get the change merged into the target branch.
+
+![Merge Immediately](img/merge_train_immediate_merge_v12_6.png)
+
+WARNING:
+Each time you merge a merge request immediately, the current merge train
+is recreated and all pipelines restart.
+
+## Troubleshooting
+
+### Merge request dropped from the merge train immediately
+
+If a merge request is not mergeable (for example, it's a draft merge request, there is a merge
+conflict, etc.), your merge request is dropped from the merge train automatically.
+
+In these cases, the reason for dropping the merge request is in the **system notes**.
+
+To check the reason:
+
+1. Open the merge request that was dropped from the merge train.
+1. Open the **Discussion** tab.
+1. Find a system note that includes either:
+ - The text **... removed this merge request from the merge train because ...**
+ - **... aborted this merge request from the merge train because ...**
+ The reason is given in the text after the **because ...** phrase.
+
+![Merge Train Failure](img/merge_train_failure.png)
+
+### Merge When Pipeline Succeeds cannot be chosen
+
+[Merge When Pipeline Succeeds](../../user/project/merge_requests/merge_when_pipeline_succeeds.md)
+is currently unavailable when Merge Trains are enabled.
+
+See [the related issue](https://gitlab.com/gitlab-org/gitlab/-/issues/12267)
+for more information.
+
+### Merge Train Pipeline cannot be retried
+
+When a pipeline for merge trains fails the merge request is dropped from the train and the pipeline can't be retried.
+Pipelines for merge trains run on the merged result of the changes in the merge request and
+the changes from other merge requests already on the train. If the merge request is dropped from the train,
+the merged result is out of date and the pipeline can't be retried.
+
+Instead, you should [add the merge request to the train](#add-a-merge-request-to-a-merge-train)
+again, which triggers a new pipeline.
+
+### Unable to add to merge train with message "The pipeline for this merge request failed."
+
+Sometimes the **Start/Add to Merge Train** button is not available and the merge request says,
+"The pipeline for this merge request failed. Please retry the job or push a new commit to fix the failure."
+
+This issue occurs when [**Pipelines must succeed**](../../user/project/merge_requests/merge_when_pipeline_succeeds.md#only-allow-merge-requests-to-be-merged-if-the-pipeline-succeeds)
+is enabled in **Settings > General > Merge requests**. This option requires that you
+run a new successful pipeline before you can re-add a merge request to a merge train.
+
+Merge trains ensure that each pipeline has succeeded before a merge happens, so
+you can clear the **Pipelines must succeed** check box and keep
+**Enable merge trains and pipelines for merged results** (merge trains) enabled.
+
+If you want to keep the **Pipelines must succeed** option enabled along with Merge
+Trains, create a new pipeline for merged results when this error occurs:
+
+1. Go to the **Pipelines** tab and click **Run pipeline**.
+1. Click **Start/Add to merge train when pipeline succeeds**.
+
+See [the related issue](https://gitlab.com/gitlab-org/gitlab/-/issues/35135)
+for more information.
+
+### Merge Trains feature flag **(PREMIUM SELF)**
+
+In [GitLab 13.6 and later](https://gitlab.com/gitlab-org/gitlab/-/issues/244831),
+you can [enable or disable merge trains in the project settings](#enable-merge-trains).
+
+In GitLab 13.5 and earlier, merge trains are automatically enabled when
+[pipelines for merged results](pipelines_for_merged_results.md) are enabled.
+To use pipelines for merged results without using merge trains, you can enable a
+[feature flag](../../user/feature_flags.md) that blocks the merge trains feature.
+
+[GitLab administrators with access to the GitLab Rails console](../../administration/feature_flags.md)
+can enable the feature flag to disable merge trains:
+
+```ruby
+Feature.enable(:disable_merge_trains)
+```
+
+After you enable this feature flag, all existing merge trains are cancelled and
+the **Start/Add to Merge Train** button no longer appears in merge requests.
+
+To disable the feature flag, and enable merge trains again:
+
+```ruby
+Feature.disable(:disable_merge_trains)
+```
diff --git a/doc/ci/pipelines/pipelines_for_merged_results.md b/doc/ci/pipelines/pipelines_for_merged_results.md
new file mode 100644
index 00000000000..910c6415cfd
--- /dev/null
+++ b/doc/ci/pipelines/pipelines_for_merged_results.md
@@ -0,0 +1,135 @@
+---
+stage: Verify
+group: Pipeline Execution
+info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
+type: reference
+last_update: 2019-07-03
+---
+
+# Pipelines for merged results **(PREMIUM)**
+
+> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/7380) in [GitLab Premium](https://about.gitlab.com/pricing/) 11.10.
+
+When you submit a merge request, you are requesting to merge changes from a
+source branch into a target branch. By default, the CI pipeline runs jobs
+against the source branch.
+
+With *pipelines for merged results*, the pipeline runs as if the changes from
+the source branch have already been merged into the target branch. The commit shown for the pipeline does not exist on the source or target branches but represents the combined target and source branches.
+
+![Merge request widget for merged results pipeline](img/merged_result_pipeline.png)
+
+If the pipeline fails due to a problem in the target branch, you can wait until the
+target is fixed and re-run the pipeline.
+This new pipeline runs as if the source is merged with the updated target, and you
+don't need to rebase.
+
+The pipeline does not automatically run when the target branch changes. Only changes
+to the source branch trigger a new pipeline. If a long time has passed since the last successful
+pipeline, you may want to re-run it before merge, to ensure that the source changes
+can still be successfully merged into the target.
+
+When the merge request can't be merged, the pipeline runs against the source branch only. For example, when:
+
+- The target branch has changes that conflict with the changes in the source branch.
+- The merge request is a [**Draft** merge request](../../user/project/merge_requests/drafts.md).
+
+In these cases, the pipeline runs as a [pipeline for merge requests](merge_request_pipelines.md)
+and is labeled as `detached`. If these cases no longer exist, new pipelines
+again run against the merged results.
+
+Any user who has developer [permissions](../../user/permissions.md) can run a
+pipeline for merged results.
+
+## Prerequisites
+
+To enable pipelines for merge results:
+
+- You must have the [Maintainer role](../../user/permissions.md).
+- You must be using [GitLab Runner](https://gitlab.com/gitlab-org/gitlab-runner) 11.9 or later.
+- You must not be using
+ [fast forward merges](../../user/project/merge_requests/fast_forward_merge.md) yet.
+ To follow progress, see [#58226](https://gitlab.com/gitlab-org/gitlab/-/issues/26996).
+- Your repository must be a GitLab repository, not an
+ [external repository](../ci_cd_for_external_repos/index.md).
+
+## Enable pipelines for merged results
+
+To enable pipelines for merged results for your project:
+
+1. [Configure your CI/CD configuration file](merge_request_pipelines.md#configure-pipelines-for-merge-requests)
+ so that the pipeline or individual jobs run for merge requests.
+1. Visit your project's **Settings > General** and expand **Merge requests**.
+1. Check **Enable merged results pipelines**.
+1. Click **Save changes**.
+
+WARNING:
+If you select the check box but don't configure your CI/CD to use
+pipelines for merge requests, your merge requests may become stuck in an
+unresolved state or your pipelines may be dropped.
+
+## Using Merge Trains
+
+When you enable [Pipelines for merged results](#pipelines-for-merged-results),
+GitLab [automatically displays](merge_trains.md#add-a-merge-request-to-a-merge-train)
+a **Start/Add Merge Train button**.
+
+Generally, this is a safer option than merging merge requests immediately, because your
+merge request is evaluated with an expected post-merge result before the actual
+merge happens.
+
+For more information, read the [documentation on Merge Trains](merge_trains.md).
+
+## Automatic pipeline cancellation
+
+> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/12996) in [GitLab Premium](https://about.gitlab.com/pricing/) 12.3.
+
+GitLab CI/CD can detect the presence of redundant pipelines, and cancels them
+to conserve CI resources.
+
+When a user merges a merge request immediately within an ongoing merge
+train, the train is reconstructed, because it recreates the expected
+post-merge commit and pipeline. In this case, the merge train may already
+have pipelines running against the previous expected post-merge commit.
+These pipelines are considered redundant and are automatically
+canceled.
+
+## Troubleshooting
+
+### Pipelines for merged results not created even with new change pushed to merge request
+
+Can be caused by some disabled feature flags. Please make sure that
+the following feature flags are enabled on your GitLab instance:
+
+- `:merge_ref_auto_sync`
+
+To check and set these feature flag values, please ask an administrator to:
+
+1. Log into the Rails console of the GitLab instance:
+
+ ```shell
+ sudo gitlab-rails console
+ ```
+
+1. Check if the flags are enabled or not:
+
+ ```ruby
+ Feature.enabled?(:merge_ref_auto_sync)
+ ```
+
+1. If needed, enable the feature flags:
+
+ ```ruby
+ Feature.enable(:merge_ref_auto_sync)
+ ```
+
+### Intermittently pipelines fail by `fatal: reference is not a tree:` error
+
+Since pipelines for merged results are a run on a merge ref of a merge request
+(`refs/merge-requests/<iid>/merge`), the Git reference could be overwritten at an
+unexpected timing. For example, when a source or target branch is advanced.
+In this case, the pipeline fails because of `fatal: reference is not a tree:` error,
+which indicates that the checkout-SHA is not found in the merge ref.
+
+This behavior was improved at GitLab 12.4 by introducing [Persistent pipeline refs](../troubleshooting.md#fatal-reference-is-not-a-tree-error).
+You should be able to create pipelines at any timings without concerning the error.