プル リクエストのマージ チェック
Pull requests provide a way to do peer code reviews and merges as part of a branch-based development workflow. As your team grows, you may need to set restrictions about when pull requests can be merged to protect your production code and keep code quality high. Merge checks can help you do this.
On this page:
マージ チェック
Merge checks stop pull requests from being merged until they meet requirements that you’ve set. Your requirements can be based a range of things, including the number of reviewers who have approved the pull request, or the result of a Code Insights report. This ensures that pull requests are fully vetted before they’re merged. It also helps to avoid the problem of code review blockages and the need to completely lock down a repository.
既定のマージ チェック
Bitbucket Data Center and Server comes with some default merge checks. These can be enabled (or disabled) at the project level for all repositories in a project, or for individual repositories.
The default merge checks that come with Bitbucket are:
- すべてのレビュアーが承認します - マージ前にすべてのレビュアーが承認する必要があります。
- 最小承認数 - マージ前に指定した数の承認が必要です。
- 最小限の成功ビルド - マージ前に指定した数の成功ビルドが必要です。
- No 'needs work' status - blocks the merge if any reviewers have marked the pull request as 'needs work'.
- 未完了のタスクはありません - マージ前にすべてのタスクが完了されている必要があります。
In addition to minimum approvals for a pull request, you can also set default reviewers. If both of these checks have been configured, they both need to be met in order to merge. In other words, meeting the minimum number of approvals won't be enough to merge if the default reviewers have not approved the pull request.
プロジェクトのすべてのリポジトリにマージ チェックを構成
プロジェクト レベルでマージ チェックを有効化 (または無効化) すると、プロジェクト設定を継承するよう設定されたリポジトリのマージ チェックが変更されます。個々のリポジトリのマージ チェックを変更したことがある場合、プロジェクト レベルでマージ チェックを設定してもそのリポジトリの設定は変更されません。
プロジェクト内のリポジトリに対してマージ チェックを有効化 (または無効化) する方法 (プロジェクト管理権限が必要)
- [プロジェクト設定] > [マージ チェック] に移動します。
- トグルをクリックしてマージ チェックを有効化 (または無効化) します。
プロジェクトで継承に設定されたリポジトリのマージ チェックは、この新しい設定を反映するようになります。リポジトリ レベルで明示的に設定されているマージ チェックは影響を受けません。
個々のリポジトリ用にマージ チェックを構成
リポジトリ レベルでマージ チェックを有効化 (または無効化) すると、そのリポジトリで作成されるすべてのプル リクエストでマージ チェックが有効化されす。リポジトリ レベルでマージ チェックを構成すると、プロジェクト レベルで構成されたマージチェックがオーバーライドされます。個々のリポジトリにマージ チェックを構成していない場合、プロジェクト レベルで有効化されたマージ チェックが継承されます。
1 つのリポジトリでマージ チェックを有効化 (または無効化) する方法 (リポジトリ管理権限が必要)
- [リポジトリ設定] > [マージ チェック] に移動します。
- マージ チェックの右側のドロップ メニューを使用して設定します。
- 継承 - プロジェクト レベルで設定された構成を使用します。
- 有効 - マージ チェックの条件を適用します。
- 無効 - マージ チェックの条件を無視します。
設定すると、プロジェクト レベルでマージ チェック構成に加えられたあらゆる変更は、プロジェクト構成とは独立して変更されるため、このリポジトリでは無視されます。
マージ チェック構成の継承
By default, Bitbucket comes with merge checks disabled at the project and repository level. Unless merge checks were configured at the repository level, enabling or disabling merge checks at the project level inherits the configuration at the repository level.
たとえば、プロジェクトで [未完了のタスクはありません] マージ チェックを有効化して、リポジトリのマージ チェック構成が変更されなかった場合、それぞれのリポジトリでは [未完了のタスクはありません] マージ チェックが有効化されます。
マージ チェックが無効 (プロジェクト レベル) | マージ チェックが無効 (リポジトリ レベル) |
マージ チェックが有効 (プロジェクト レベル) | マージ チェックが有効 (リポジトリ レベル) |
ある特定のリポジトリで [未完了のタスクはありません] マージ チェックが適切でないと判断したとします。プロジェクト レベルでの構成内容を問わず、個々のリポジトリのマージ チェックを変更できます。プロジェクト レベルで [未完了のタスクはありません] マージ チェック構成に加えられた変更は、プロジェクト構成とは独立して変更されるため、このリポジトリでは無視されます。
マージ チェックが有効 (プロジェクト レベル) | マージ チェックが無効 (リポジトリ レベル) |
新しいマージ チェックの追加
追加のマージ チェックはシステム管理者がインストールでき、プロジェクト内のすべてのリポジトリに対して有効化することも、個々のリポジトリに対して有効化することもできます。
Atlassian Marketplace からマージ チェックを追加する方法 (システム管理者権限が必要)
- [プロジェクト設定] > [マージ チェック] に移動します。
- [マージ チェックの追加] をクリックします。
- 追加するマージ チェックを検索し、[インストール] をクリックします。
新しいマージ チェックを追加したら、既定のマージ チェックと同じように有効化 (または無効化) できます。
マージ チェックの作成
独自のマージ チェック プラグインを作成することもできます。
Code Insights merge checks
You can block pull requests from being merged until their Code Insights reports meet your requirements. You can set these merge checks for all the repositories in a project, or a single repository, and your requirements can be based on whether:
- a specific report is present
- the report passes or fails
- the report adds annotations of a certain severity to the diff
Annotations only block merging if they are on the diff. If they’re somewhere else on a changed file, or on a file that hasn’t changed they won’t block the merge.
To add a Code Insights merge check for all the repositories in a project (requires project admin permissions):
- Go to Project settings > Code Insights.
- Enter the report key of your required report. You can find this on the report in the bottom right.
- Enter its required status and its annotation requirements.
- Click add.
To add a Code Insights merge check for a repository (requires repository admin permissions):
- Go to Repository settings > Code Insights.
- Enter the report key of your required report. You can find this on the report in the bottom right.
- Enter its required status and its annotation requirements.
- Click add.
必須ビルドのマージ チェック
この機能は、Bitbucket Data Center ライセンスを持っている場合にのみ利用できます。
While the minimum successful builds merge check lets you require at least the specified number of successful builds, you can use the required builds merge check for requiring specific builds to successfully pass before a pull request can be merged into specified target branches.
Using required builds provides a simple but powerful interface to ensure code quality by protecting critical branches in your repository.
To use required builds, you must have Bamboo 7.1+ or the Bitbucket Server Integration Plugin version 2.0.0+. See Link your CI server for more details on integration guides.
To add a required build merge check for pull requests in a repository (requires repository admin permissions):
Go to Repository settings > Required builds.
Select Add required builds.
From the Add required builds page, input the details as described in the table below.
- [保存] を選択します。
フィールド | 説明 |
---|---|
Add builds | Add any build keys here that will need to successfully pass before merging a pull request. The build key will depend on the CI tool used to generate the build. For example;
|
Select protected target branches | Choose from a list of branches. Any pull request with a target branch that matches this setting will need to have successful builds on the latest commit before it can be merged. You can set this merge check to apply to Any branch in the repository, or you can be more specific by choosing:
|
Select exempt source branches | In some cases, you may want to add specific source branches that won’t need to pass in the selected required build(s). For example; you could allow urgent fixes to skip build checks by adding the Branch pattern Leave this option set to None if you don’t want to add an exemption, otherwise choose from the following:
|