Bitbucket is getting a new navigation

We’re rolling out these changes, so the documentation may not match your experience in the Bitbucket Cloud app. Read about the new Bitbucket navigation

Expression language

Use Expression Language to build conditional expressions and make your pipelines more flexible.

This document describes a compact and safe boolean expression language designed for evaluating runtime context within pipeline configurations.

Expressions written in this language are evaluated to either true or false. The language supports the use of variables, literals, comparison operators, logical operations, grouping of expressions, and a set of simple functions to enable flexible and precise condition evaluation.

Where is Expression Language used ?

Expression language is currently being used in the following:

Example

  • (var_1 > 100 && var_1 <= 200) || var_2 == "ok" && var_3 == true

  • glob(var_1, "feature/*") && var_2 != "ok"

Expression Form

  • Must evaluate to a boolean (true or false).

  • Non-boolean results (e.g., "hello world") are invalid.

Literals

  • String: "text"

  • Number: 42, 3.14

  • Boolean: true, false

  • null: Not supported. Use the string "null" if required (for example, value == "null").

Variables

  • Refer to variables directly by name (no $ prefix).

Operators

  • == — Equality

  • != — Inequality

  • && — Logical AND

  • || — Logical OR

  • ! — Logical NOT

  • () Grouping

  • >, >=, <, <= Comparison operators

Functions

Functions

Trigger conditions support functions for pattern matching and changeset-based filtering. Functions can be combined with logical operators (&&, ||, !) for advanced matching.

The glob() function

The glob() function enables flexible pattern matching in trigger conditions, allowing you to match branches, tags, or other variables using wildcards and brace expansion. It returns true if the value matches the pattern, and false otherwise.

Syntax and parameters

Syntax: glob(value, "pattern")

  • value: The variable to test (e.g., BITBUCKET_BRANCH, BITBUCKET_TAG)

  • pattern: The glob pattern to match (must be in quotes; supports wildcards like *, ?, and brace expansion {}; patterns are case-sensitive)

Behavior

The glob() function follows the same pattern-matching rules as using glob patterns on the Pipelines yaml file.

You can combine glob() with logical operators (&&, ||, !) in condition expressions for advanced matching.

Examples:

  • Match feature branches:
    glob(BITBUCKET_BRANCH, "feature/*")
    Matches any branch that starts with "feature/".

  • Match version tags:
    glob(BITBUCKET_TAG, "v1.*")
    Matches tags like "v1.0", “v1.1” etc

  • Match multiple patterns using brace expansion:
    glob(BITBUCKET_BRANCH, "{main,develop,staging}")
    Matches if the branch is "main", "develop", or "staging".

  • Match all with glob **:
    glob(BITBUCKET_BRANCH, "**")
    Matches any branch name.

The changesetInclude() function

The changesetInclude() function triggers pipelines based on which files changed in a commit. It returns true if ANY changed file matches ANY of the specified patterns.

Syntax: changesetInclude("pattern1", "pattern2", ...)

  • patterns: One or more glob patterns to match against changed file paths

Behavior:

  • Returns true if any changed file matches any of the provided patterns

  • Returns false if no files match or if there are no changed files

  • Patterns use glob syntax (same as step-level changeset conditions)

Examples:

  • Trigger when source files change:
    changesetInclude("src/**")

  • Trigger for multiple directories:
    changesetInclude("src/**", "lib/**")

  • Combine with branch condition:
    BITBUCKET_BRANCH == "main" && changesetInclude("src/**")

  • Use OR logic:
    changesetInclude("backend/**") || changesetInclude("shared/**")

The changesetExclude() function

The changesetExclude() function triggers pipelines when changes exist outside of specified patterns. It returns true if at least one changed file does NOT match any of the specified patterns.

Syntax: changesetExclude("pattern1", "pattern2", ...)

  • patterns: One or more glob patterns to exclude

Behavior:

  • Returns true if any changed file does NOT match any of the provided patterns

  • Returns false if all files match the patterns or if there are no changed files

  • Useful for skipping pipelines when only certain files (like docs) change

Examples:

  • Skip when only docs change:
    changesetExclude("docs/**", "*.md")

  • Run unless only config files changed:
    changesetExclude("*.json", "*.yml")

  • Combine with other conditions:
    BITBUCKET_BRANCH == "main" && changesetExclude("docs/**")

Still need help?

The Atlassian Community is here for you.