SpecialistOff.NET / Вопросы / Статьи / Фрагменты кода / Резюме / Метки / Помощь / Файлы
НазадThis BitbucketPullrequestPoller periodically polls Bitbucket for new or updated pull requests. It uses Bitbuckets powerful Pull Request REST API to gather the information needed.
The BitbucketPullrequestPoller accepts the following arguments:
ownerThe owner of the Bitbucket repository. All Bitbucket Urls are of the form https://bitbucket.org/owner/slug/.
slugThe name of the Bitbucket repository.
authAuthorization data tuple (usename, password) (optional). If set, it will be used as authorization headers at Bitbucket API.
branchA single branch or a list of branches which should be processed. If it is None (the default) all pull requests are used.
pollIntervalInterval in seconds between polls, default is 10 minutes.
pollAtLaunchDetermines when the first poll occurs. True = immediately on launch, False = wait for one pollInterval (default).
categorySet the category to be used by the BitbucketPullrequestPoller. This will then be set in any changes generated by the BitbucketPullrequestPoller, and can be used in a Change Filter for triggering particular builders.
projectSet the name of the project to be used by the BitbucketPullrequestPoller. This will then be set in any changes generated by the BitbucketPullrequestPoller, and can be used in a Change Filter for triggering particular builders.
pullrequest_filterA callable which takes one parameter, the decoded Python object of the pull request JSON. If it returns False, the pull request is ignored. It can be used to define custom filters based on the content of the pull request. See the Bitbucket documentation for more information about the format of the response. By default, the filter always returns True.
usetimestampsParse each revision’s commit timestamp (default is True), or ignore it in favor of the current time, so that recently processed commits appear together in the waterfall page.
bitbucket_property_whitelistA list of fnmatch expressions which match against the flattened pull request information JSON prefixed with bitbucket. For example bitbucket.id represents the pull request ID. Available entries can be looked up in the BitBucket API Documentation or by examining the data returned for a pull request by the API.
encodingThis parameter is deprecated and has no effects. Author’s name and commit message are always parsed in 'utf-8'.
A minimal configuration for the Bitbucket pull request poller might look like this:
from buildbot.plugins import changes
c['change_source'] = changes.BitbucketPullrequestPoller(
owner='myname',
slug='myrepo',
)
Here is a more complex configuration using a pullrequest_filter. The pull request is only processed if at least 3 people have already approved it:
def approve_filter(pr, threshold):
approves = 0
for participant in pr['participants']:
if participant['approved']:
approves = approves + 1
if approves < threshold:
return False
return True
from buildbot.plugins import changes
c['change_source'] = changes.BitbucketPullrequestPoller(
owner='myname',
slug='myrepo',
branch='mybranch',
project='myproject',
pullrequest_filter=lambda pr : approve_filter(pr,3),
pollInterval=600,
)
Warning
Anyone who can create pull requests for the Bitbucket repository can initiate a change, potentially causing the buildmaster to run arbitrary code.