Bitbucket Context reference

The following variables are available at the root level when writing conditions and templates. For variables that are custom objects, see their properties further down the page.

all function

Return True if bool(x) is True for all values x in the iterable.

If the iterable is empty, return True.

any function

Return True if bool(x) is True for any x in the iterable.

If the iterable is empty, return False.

author Account

close_source_branch bool

A boolean flag indicating if merging the pull request closes the source branch.

closed_by Account

comment_count int

The number of comments for a specific pull request.

comments Comments

commits Commits

contains_any_fnmatches function

contains_any_fnmatches(files, ['api/*', 'tests/*'])

contains_any_globs function

contains_any_globs(files, ['api/**', 'tests/*.py'])

contains_fnmatch function

contains_fnmatch(title, 'WIP*')

contains_glob function

contains_glob(file.filename, 'app/**/*.py')

contains_regex function

contains_regex(title, 'WIP.*')

count function

Return the number of items in a container.

created_on datetime

The ISO8601 timestamp the request was created.

date function

Parses a date from a string using dateparser.

date('3 days ago')

date('8/10/1995')

description str

destination PullRequestEndpoint

diff Diff

diffstat Diffstats

glob function

glob('*.py')

groups Groups

id int

The pull request's unique ID. Note that pull request IDs are only unique within their associated repository.

len function

Return the number of items in a container.

length function

Return the number of items in a container.

merge_commit Commit

participants Participants

The list of users that are collaborating on this pull request. Collaborators are user that:

    * are added to the pull request as a reviewer (part of the reviewers
      list)
    * are not explicit reviewers, but have commented on the pull request
    * are not explicit reviewers, but have approved the pull request

    Each user is wrapped in an object that indicates the user's role and
    whether they have approved the pull request. For performance reasons,
    the API only returns this list when an API requests a pull request by
    id.

percent_chance method

Returns True if this PR is within the percent_chance

percent_chance(33) will be True on roughly 1/3 of PRs

reason str

Explains why a pull request was declined. This field is only applicable to pull requests in rejected state.

regex function

regex('WIP: .*')

rendered dict

User provided pull request text, interpreted in a markup language and rendered in HTML

reviewers Accounts

The list of users that were added as reviewers on this pull request when it was created. For performance reasons, the API only includes this list on a pull request's self URL.

state str

The pull request's current status.

statuses Statuses

summary dict

task_count int

The number of open tasks for a specific pull request.

text_list function

Returns a readable, comma-separated list of items for printing in templates.

text_list(['a', 'b', 'c', 'd']) == 'a, b, c or d'

text_list(['a', 'b', 'c'], 'and') == 'a, b and c'

text_list(['a', 'b'], 'and') == 'a and b'

text_list(['a']) == 'a'

text_list([]) == ''

title str

Title of the pull request.

type str

updated_on datetime

The ISO8601 timestamp the request was last updated.

Account

account_id str

display_name str

nickname str

Account name defined by the owner. Should be used instead of the "username" field. Note that "nickname" cannot be used in place of "username" in URLs and queries, as "nickname" is not guaranteed to be unique.

type str

uuid str

Branch

name str

Comment

content dict

created_on datetime

deleted bool

id int

markdown str

pullrequest dict

type str

updated_on datetime

user Account

Comments

exclude method

Filter down the list of objects using not contains behavior. Chainable with include.

files.exclude("*.md")

files.include("src/*").exclude("*.md")

get method

Gets a specific item in the list using the primary attribute (i.e. name, number, username).

ids list of int

include method

Filter down the list of objects using contains behavior. Chainable with exclude.

files.include("src/*")

files.include("src/*").exclude("*.md")

Commit

author dict

date datetime

hash str

message str

parents list of dict

repository dict

summary dict

type str

user str

Commits

exclude method

Filter down the list of objects using not contains behavior. Chainable with include.

files.exclude("*.md")

files.include("src/*").exclude("*.md")

get method

Gets a specific item in the list using the primary attribute (i.e. name, number, username).

hashes list of str

include method

Filter down the list of objects using contains behavior. Chainable with exclude.

files.include("src/*")

files.include("src/*").exclude("*.md")

Diff

diff str

lines_added list of str

lines_modified list of str

lines_removed list of str

Diffstat

lines_added int

lines_removed int

new dict

old str

path str

status str

type str

Diffstats

added Diffstats

exclude method

Filter down the list of objects using not contains behavior. Chainable with include.

files.exclude("*.md")

files.include("src/*").exclude("*.md")

get method

Gets a specific item in the list using the primary attribute (i.e. name, number, username).

include method

Filter down the list of objects using contains behavior. Chainable with exclude.

files.include("src/*")

files.include("src/*").exclude("*.md")

modified Diffstats

paths list of str

removed Diffstats

renamed Diffstats

Group

A PullApprove review group

author_value int

conditions list

description str

is_active bool

is_passing bool

labels dict

name str

request int

request_order str

required int

requirements list

reviewed_for str

score int

state str

teams list

type str

users list of str

users_approved list

users_available list

users_pending list

users_rejected list

users_requested list

users_unavailable list

users_unrequested list

Groups

Groups is a list of Group objects with a few handy shortcuts.

active Groups

approved Groups

exclude method

Filter down the list of objects using not contains behavior. Chainable with include.

files.exclude("*.md")

files.include("src/*").exclude("*.md")

get method

Gets a specific item in the list using the primary attribute (i.e. name, number, username).

inactive Groups

include method

Filter down the list of objects using contains behavior. Chainable with exclude.

files.include("src/*")

files.include("src/*").exclude("*.md")

names list of str

optional Groups

passing Groups

pending Groups

rejected Groups

required Groups

users_approved list

users_available list

users_pending list

users_rejected list

users_unavailable list

Participant

approved bool

nickname str

participated_on datetime

The ISO8601 timestamp of the participant's action. For approvers, this is the time of their approval. For commenters and pull request reviewers who are not approvers, this is the time they last commented, or null if they have not commented.

role str

state str

type str

user Account

Participants

exclude method

Filter down the list of objects using not contains behavior. Chainable with include.

files.exclude("*.md")

files.include("src/*").exclude("*.md")

get method

Gets a specific item in the list using the primary attribute (i.e. name, number, username).

include method

Filter down the list of objects using contains behavior. Chainable with exclude.

files.include("src/*")

files.include("src/*").exclude("*.md")

nicknames list of str

PullRequestEndpoint

branch Branch

branch_name str

commit Commit

repository Repository

Repository

full_name str

The concatenation of the repository owner's username and the slugified name, e.g. "evzijst/interruptingcow". This is the same string used in Bitbucket URLs.

name str

type str

uuid str

The repository's immutable id. This can be used as a substitute for the slug segment in URLs. Doing this guarantees your URLs will survive renaming of the repository by its owner, or even transfer of the repository to a different user.

Status

commit dict

created_on datetime

description str

key str

name str

refname str

repository dict

state str

type str

updated_on datetime

Statuses

exclude method

Filter down the list of objects using not contains behavior. Chainable with include.

files.exclude("*.md")

files.include("src/*").exclude("*.md")

failed Statuses

get method

Gets a specific item in the list using the primary attribute (i.e. name, number, username).

in_progress Statuses

include method

Filter down the list of objects using contains behavior. Chainable with exclude.

files.include("src/*")

files.include("src/*").exclude("*.md")

keys list of str

stopped Statuses

successful Statuses