GitLab 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.
approvals_before_merge str
assignee User
assignees Users
author User
blocking_discussions_resolved bool
changes_count str
closed_at str
closed_by str
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_at str
date function
description str
diff Diff
diff_refs dict
discussion_locked str
downvotes int
draft bool
first_contribution bool
first_deployed_to_production_at str
force_remove_source_branch bool
glob function
glob('*.py')
has_conflicts bool
head_pipeline dict
id int
iid int
labels list of str
latest_build_finished_at str
latest_build_started_at str
len function
Return the number of items in a container.
length function
Return the number of items in a container.
merge_commit_sha str
merge_error str
merge_status str
merge_when_pipeline_succeeds bool
merged_at str
merged_by str
milestone Milestone
number int
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
pipeline Pipeline
project_id int
reference str
references dict
regex function
regex('WIP: .*')
reviewers Users
sha str
should_remove_source_branch str
source_branch str
source_project_id int
squash bool
squash_commit_sha str
state str
subscribed bool
target_branch str
target_project_id int
task_completion_status dict
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([]) == ''
time_stats dict
title str
updated_at str
upvotes int
user dict
user_notes_count int
web_url str
work_in_progress bool
Diff
A git diff for the MR
diff str
lines_added list of str
lines_modified list of str
lines_removed list
Milestone
created_at str
description str
due_date str
expired str
id int
iid int
project_id int
start_date str
state str
title str
updated_at str
web_url str
Pipeline
created_at str
id int
project_id int
ref str
sha str
source str
status str
updated_at str
web_url str
User
A GitLab user.
avatar_url str
id int
name str
state str
username str
web_url str
Users
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")