Version
latest
(9.5.0)
9.4.0
9.3.0
9.2.0
9.1.1
9.0.0
8.36.0
8.35.0
8.34.0
8.33.0
8.32.0
8.31.0
8.30.0
8.29.0
8.28.0
8.27.0
8.26.0
8.25.0
8.24.0
8.23.0
8.22.0
8.21.0
8.20.0
8.19.0
8.18.0
8.17.0
8.16.0
8.15.0
8.14.0
8.13.0
8.12.0
8.11.0
8.10.0
8.9.0
8.8.0
8.7.0
8.6.0
8.5.0
8.4.0
8.3.0
8.2.1
8.2.0
8.1.0
8.0.0
7.13.0
7.12.0
7.11.1
7.11.0
7.10.0
7.9.0
7.8.0
7.7.0
7.6.0
7.5.0
7.4.0
7.3.0
7.2.0
7.1.0
7.0.0
6.58.0
6.57.0
6.56.0
6.55.1
6.55.0
6.54.0
6.53.0
6.52.0
6.51.0
6.50.0
6.49.0
6.48.0
6.47.0
6.46.0
6.45.0
6.44.0
6.43.0
6.42.0
6.41.0
6.40.0
6.39.0
6.38.0
6.37.0
6.36.0
6.35.0
6.34.0
6.33.0
6.32.0
6.31.0
6.30.1
6.30.0
6.29.0
6.28.0
6.27.0
6.26.0
6.25.0
6.24.0
6.23.0
6.22.0
6.21.0
6.20.0
6.19.1
6.19.0
6.18.0
6.17.0
Custom Merge Check
Custom merge checks allow you to cause a pull request merge to be vetoed . The same functionality can also be achieved using a Conditional Merge Check . However, custom merge checks are most useful when you want to dynamically generate the veto message.
Reject merge with message Custom merge checks should return a RepositoryHookResult
object. To block a merge, you should call the static RepositoryHookResult.rejected() method.
Enforcing reviewers in several timezones with dynamic veto message The intention of this hook is to ensure that the author and reviewers are in at least three time zones, as a mechanism of ensuring people in different offices are aware of code changes.
import com.atlassian.bitbucket.hook.repository.RepositoryHookResult
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.bitbucket.timezone.UserTimeZoneSupplier
def final nTimeZonesRequired = 3
def participants = mergeRequest.pullRequest.reviewers*.user
participants <<
mergeRequest.pullRequest.author.user
def
userTimeZoneSupplier
=
ComponentLocator
.getComponent(UserTimeZoneSupplier)
def
timeZones
=
participants
.collect { participant ->
userTimeZoneSupplier.getTimeZone(participant)
}
def actualTimeZones = timeZones.unique().size()
if (actualTimeZones < nTimeZonesRequired) {
RepositoryHookResult.rejected("Not enough timezones covered",
"You need reviewers in ${nTimeZonesRequired - actualTimeZones} more timezone(s). " +
"Currently you have: ${timeZones.join(", ")}.")
}