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

式言語

式言語を使用して条件式を構築し、パイプラインの柔軟性を高めます。

このドキュメントでは、パイプライン構成内のランタイム コンテキストを評価するために設計されたコンパクトで安全なブール式言語について説明します。

この言語で記述された式は true または false のいずれかに評価されます。この言語は、変数、リテラル、比較演算子、論理演算、式のグループ化、および一連の単純な関数の使用をサポートしており、柔軟で正確な条件評価を可能にします。

式言語はどこで使われますか?

式言語は現在、次の用途で使用されています。

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

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

式フォーム

  • ブール値 (true または false) に評価される必要があります。

  • ブール値以外の結果 (例: "hello world") は無効です。

リテラル

  • 文字列: "text"

  • 数値: 423.14

  • ブール値: truefalse

  • null: サポートされていません。必要に応じて文字列 "null" を使用してください (たとえば、value == "null")。

Variables

  • 変数を名前で直接参照する ($ プレフィックスなし)。

演算子

  • == — 等式

  • != — 不等式

  • && — 論理 AND

  • || — 論理 OR

  • ! — 論理 NOT

  • () グループ化

  • >, >=, <, <= 比較演算子

関数

関数

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

glob() 関数

glob() 関数により、トリガー条件での柔軟なパターン マッチングが可能になり、ワイルドカードと中括弧の展開を使用して、ブランチ、タグ、またはその他の変数を一致させることができます。値がパターンと一致する場合は true を返し、それ以外の場合は false を返します。

構文とパラメーター

構文: glob(value, "pattern")

  • value: テストする変数 (例えば、BITBUCKET_BRANCHBITBUCKET_TAG)

  • pattern: 一致する glob パターン (引用符で囲む必要があります。*?、などのワイルドカードおよび、{} などの中括弧拡張をサポートします。パターンでは大文字と小文字が区別されます)

動作

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

条件式では glob() と論理演算子 (&&||!) を組み合わせて高度な一致を行うことができます。

例:

  • フィーチャー ブランチとの一致:
    glob(BITBUCKET_BRANCH, "feature/*")
    「feature/」で始まるすべてのブランチに一致します。

  • バージョン タグとの一致:
    glob(BITBUCKET_TAG, "v1.*")
    「v1.0」、「v1.1」などのタグに一致します

  • 中括弧拡張を使用した複数パターンとの一致:
    glob(BITBUCKET_BRANCH, "{main,develop,staging}")
    ブランチが「main」、「develop」、「staging」のいずれかである場合に一致します 。

  • glob ** によるすべてとの一致:
    glob(BITBUCKET_BRANCH, "**")
    任意のブランチ名と一致します

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)

例:

  • 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

例:

  • 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/**")

さらにヘルプが必要ですか?

アトラシアン コミュニティをご利用ください。