Workzone features a powerful boolean expression parser that lets you define advanced merge conditions like:
requiredBuildsCount > 1 & ( approvalQuota >= 50% | groupQuota >= 2 )
Workzone will merge a pull request if more than 50% of assigned reviewers have approved OR at least to members of each assigned reviewers group have approved AND there is a successful build result against HEAD of source branch.
The following terms can be used for creating complex boolean merge conditions:
- approvalCount: the absolute number of reviewer approvals required to merge the pull request. Ex:
approvalCount >= 2
- approvalQuota: the percentage of approvals among all reviewers assigned to a pull request. Once that percentage is reached, Workzone attempts to merge the pull request automatically. Ex:
approvalQuota >= 51%
- mandatoryApprovalCount: the absolute number of mandatory reviewer approvals required to merge the pull request. Ex
mandatoryApprovalCount >= 2
- groupQuota: the number of members per reviewer group that have approved the pull request. Ex:
groupQuota > 2
. More fine-grained group quota can be achieved by naming the group. Ex:groupQuota['dev-leads'] > 2
. Once the required number of group members have approved, Workzone attempts to merge the pull request automatically. Note that if a reviewer is a member of 2 groups and both groups are configured to be reviewers, their approval counts towards each group, a member of a group doesn’t have to approve twice. - requiredBuildsCount: The number of consecutive successful builds from your Bitbucket – build server integration. If the ‘Watch build results’ box is checked, Workzone attempts to merge the pull request automatically on successful builds. Ex:
requiredBuildsCount > 0
- requiredSignaturesCount: The number of digital signature approvals required. Workzone attempts to merge the pull request automatically, once the number of signatures equals or exceeds the condition. Ex:
requiredSignaturesCount >= 3
- filePathMergeChecksPass == true: Use filePathMergeChecks == true in the Workzone Boolean Expression to evaluate file/path reviewer quota checks explicitly.
Advanced Merge Conditions with Specific Group Quota #
Advanced Merge Conditions with groupQuota are an important part of Workzone’s merge-control features.
Let’s recap on advanced merge conditions:
A boolean expression describes the merge condition in a clear and concise way. Using tokens like
approvalQuota, groupQuota, requiredSignaturesCount, requiredBuildsCount
an advanced merge condition could be expressed like
requiredBuildsCount > 1 & ( approvalQuota >= 50% | groupQuota >= 1)
Merge if: more than 1 successful build and 50% or more of reviewers have approved OR more than 1 successful build and 2 or more members per reviewer-group have approved.
GroupQuota specifies a general amount of approvals that’s applies to all reviewer groups (groups specified in Workzone’s reviewer configuration).
#
Specific named groupQuota #
Workzone now supports specifically named groupQuota where the target number of approvals can be bound to a specific group or set of groups. Given a group with name ‘abba’ above expression could now be written as
((groupQuota['abba'] > 2 & groupQuota > 1)|approvalQuota > 50%) & requiredBuildsCount > 1
Which translates to: Merge if –
more than 1 successful build and more than 50% of reviewers have approved OR more than 1 successful build and 2 or more members per reviewer-group AND 3 or more members of group ‘abba’ have approved. Note that group ‘abba’ still needs to be specified as a reviewer group.
GroupQuota still specifies a general amount of approvals required for all reviewer groups (including ‘abba’). However groupQuota[‘abba’] specifies a higher target specifically for members of group ‘abba’, i.e. at least 3 or more members of ‘abba’ need to approve the pull request.
If merge conditions need to be elevated for multiple groups, the condition can be expressed with a set of groups like
groupQuota['abba','acdc'] > 2
Best practice is to specify a general groupQuota that is lower than a named groupQuota. Specific named groupQuota conditions should be used to elevate the required approvals for a specific group. All specified groups must be part of the Workzone reviewer group configuration
Required file and path reviewer approvals #
The Workzone advanced merge condition expression can now incorporate a new condition called filePathMergeChecksPass == true. Use filePathMergeChecks == true in the Workzone Boolean Expression to evaluate file/path reviewer quota checks explicitly. This condition comes into play if the Workzone reviewer file/path configuration has also required approvals per file/path defined.
These required reviewer approvals are implied when Workzone evaluates the pull request merge condition. A Workzone merge condition like approvalQuota >= 1% & requiredBuildsCount >= 1
would effectively read as (approvalQuota >= 1% & requiredBuildsCount >= 1) & filePathMergeChecksPass == true
Workzone enforces that all necessary file/path reviewer approvals must be satisfied on top of the given merge condition.
In order to include the file/path merge condition check in the merge condition’s boolean expression include filePathMergeChecksPass == true
into the advanced merge condition.
For example to bypass required file/path reviewer approvals with a digital signature approval use
(filePathMergeChecksPass == true & requiredBuildsCount >= 1) | requiredSignaturesCount >= 1