Skip to main content
Skip table of contents

Owner rules

Define what part of the code is owned by whom, and your team:

  1. Helps to find out who should review which PR, thanks to the automatic assignment of Code Owners as reviewers to your pull requests.

  2. Can require reviews and approvals for PRs, enforced with flexible Merge Checks based on the active Code Owners. (optional)

Want to try it out first? Access the interactive playground where you can check your Code Owner rules.

Owner rule: What? is owned by Who?

The syntax for owner rules is simple

<filepattern> <members> 

<members> can consist of one or more user/group identifiers

  • @<username>for single users
  • @@<groupname> for groups. Can be either:
  • names with spaces need to be in double quotes @"<user with spaces>"

<filepattern> follows the same convention as the .gitignore plus some extras. For example, this is the behaviour for the following patterns:

  • * everything in the repository
  • **/*.java all java files
  • ci/* all files in directory ci without subdirectories
  • frontend/ all files in directory frontend with subdirectories
  • {option1,option2,optionX} provides list of options which can be matched. e.g. main.{java,js,ts} matches, main.js or main.ts. docs/{public/*,api/*} matches files under the docs/public/* and docs/api/* directories.
  • !ci/playgrounds.yml exclude code owners for selected files
  • files starting with # or ! can still be used by escaping them \!file.txt

Ordering is important! The last matching file pattern has the highest precedence. Generic rulse should be put first, followed by more specific rules.

Custom Groups

The syntax to create custom groups is

@@@<newgroupname> <members>

For the file pattern, the app uses the syntax of Bitbucketโ€™s branch permission patterns.

For details, check



**/*.java @james_gosling
**/*.scala @martin_odersky
jvm/**/*.java @brian_goetz

PR diff:


Gives active rules and Code Owners for this PR:

**/*.scala @martin_odersky
jvm/**/*.java @brian_goetz

The active Code Owners:

  • Martin

  • Brian

are added as reviewers on PR creation/updates.

Full CODEOWNERS reference

# Put this in a file called CODEOWNERS.
# Lines starting with # are comments.

# Every rule line is a file pattern that is followed by one or more code owners.

# This user will be the default owner for everything in the repo.
*                        @PeterTheHacker

# Ordering is important! The last matching file pattern has the highest precedence.
# So if only a Java file is in the pull request, PeterTheJavaExpert is the code owner
# and not the default owner PeterTheHacker.
*.java                   @PeterTheJavaExpert

# If you want, you can define your own code owner groups instead of using Bitbucket groups.
# This will define a new group MyDevs, both including users and other groups:
@@@MyDevs                @PeterTheHacker  @PeterTheJavaExpert ann@scala.lang @@JSDevs

# For Bitbucket users and groups with spaces in their name, put them into double quotes.
*.ts                     @"Paul the JSGuru" @@"Dev Ops Team"

# When your glob expression contains spaces, put the glob into double quotes.
"a/path with spaces/*"   @AnnTheScalaPro

# AnnTheScalaPro is the code owner of all files in the /src/main/scala directory at
# the root and all its descendants (e.g., /src/main/scala/com/x/y/z.scala).
/src/main/scala/         @AnnTheScalaPro

# ci/* will match all files in the directory ci, but not deeper in
# the directory hierarchy (so ci/jobs/prod.yml will not match).
ci/*                     @devops

# You can use '!' for negation in front of file pattern without any code owners afterwards,
# to unset all previously defined code owners of the files.
# e.g. devops group wants to review everything under ci (as defined above),
# except ci/playgrounds.yml, which nobody needs to review:

# It's also possible to use double-asterisk globs. Here's an example that will match
# all JS files under /src/components.
src/components/**/*.js   @@MyDevs

# GroovyMaster owns any files in the groovy directory anywhere in the
# file tree (e.g., src/main/groovy/com/x/y/z.groovy).
groovy/                  @GroovyMaster

# Files starting with a `#` or a `!` can still be used by escaping them.
\#myfile.rb              @PeterTheHacker
\!yourfile.rb            @PaulTheJSGuru

# It is important to protect CODEOWNERS file as well because otherwise it can get deleted
# or moved within a pull request; so we want to assign a code owner to it which can prevent this
CODEOWNERS               @CTO


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.