Merge when pipeline succeeds
When reviewing a merge request that looks ready to merge but still has one or more CI jobs running, you can set it to be merged automatically when the jobs pipeline succeeds. This way, you don't have to wait for the jobs to finish and remember to merge the request manually.
How it works
When you hit the "Merge When Pipeline Succeeds" button, the status of the merge request will be updated to represent the impending merge. If you cannot wait for the pipeline to succeed and want to merge immediately, this option is available in the dropdown menu on the right of the main button.
Both team developers and the author of the merge request have the option to cancel the automatic merge if they find a reason why it shouldn't be merged after all.
When the pipeline succeeds, the merge request will automatically be merged. When the pipeline fails, the author gets a chance to retry any failed jobs, or to push new commits to fix the failure.
When the jobs are retried and succeed on the second try, the merge request will automatically be merged after all. When the merge request is updated with new commits, the automatic merge is automatically canceled to allow the new changes to be reviewed.
Only allow merge requests to be merged if the pipeline succeeds
You can prevent merge requests from being merged if their pipeline did not succeed or if there are threads to be resolved.
Navigate to your project's settings page and expand the Merge requests section. In the Merge checks subsection, select the Pipelines must succeed check box and hit Save for the changes to take effect.
NOTE: Note: This setting also prevents merge requests from being merged if there is no pipeline.
From now on, every time the pipeline fails you will not be able to merge the merge request from the UI, until you make all relevant jobs pass.
When this setting is enabled, a merge request is prevented from being merged if there is no pipeline. This may conflict with some use cases where
only/except rules are used and they don't generate any pipelines.
Users that expect to be able to merge a merge request in this scenario should ensure that there is always a pipeline and that it's succesful.
For example, to that on merge requests there is always a passing job even though
only/except rules may not generate any other jobs:
enable_merge: only: merge_requests script: - echo true