2.5.3.12. BitbucketPullrequestPoller


RemiZOffAlex  Создано: 2021-12-25 02:46:26.891722  Обновлено: 2021-12-25 02:46:26.891738
classbuildbot.changes.bitbucket.BitbucketPullrequestPoller

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:

owner

The owner of the Bitbucket repository. All Bitbucket Urls are of the form https://bitbucket.org/owner/slug/.

slug

The name of the Bitbucket repository.

auth

Authorization data tuple (usename, password) (optional). If set, it will be used as authorization headers at Bitbucket API.

branch

A single branch or a list of branches which should be processed. If it is None (the default) all pull requests are used.

pollInterval

Interval in seconds between polls, default is 10 minutes.

pollAtLaunch

Determines when the first poll occurs. True = immediately on launch, False = wait for one pollInterval (default).

category

Set 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.

project

Set 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_filter

A 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.

usetimestamps

Parse 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_whitelist

A 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.

encoding

This 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.

© RemiZOffAlex