Skip to main content

YAML syntax for build triggers

Existing trigger configurations

This page details information about target-based build triggers, defined within a Workflow or a Pipeline. We recommend this approach for all new users as it offers a more granular and flexible build trigger system.

Existing configurations might use legacy, project-based triggers. Read more about them: Legacy project-based triggers.

The configuration YAML files contain the definitions for build triggers. You can configure them directly in YAML without having to use the online Workflow Editor.

Trigger syntaxClick to copy link

Triggers must be included in a triggers element within a Workflow or Pipeline. A valid trigger in the triggers element includes the type of the trigger and at least one trigger condition.

For example, the below trigger launches a build when code is pushed to the release branch.

workflows:
pipeline-tests:
triggers:
push:
- branch: "release"

Multiple matching triggersClick to copy link

We parse all triggers in a configuration YAML and start builds with all matching triggers. This means the order of the triggers doesn't matter.

For example, if you have two Workflows with push triggers with the same branch condition, both will be triggered when a commit is pushed to that branch. In the configuration below, both triggers will launch a build if a commit is pushed to the release branch:

  • The pipeline-tests Workflow specifies the release branch.
  • The pipeline-build Workflow uses a wildcard so any commit triggers a build with it.
workflows:
pipeline-tests:
triggers:
push:
- branch: "release"
[...]
pipeline-build:
triggers:
push:
- branch: "*"

Multiple trigger conditionsClick to copy link

If you define multiple trigger conditions, all of them must match to trigger a build. In the example below, a build will be triggered if:

  • A commit is pushed to the release branch.
  • Certain files have changed in the commit.
workflows:
pipeline-builds:
triggers:
push:
- branch: release
changed_files: path/to/library-a/.*

Wildcards and regexClick to copy link

We support wildcards (*) for simple text matching within all types of triggers. Wildcards are a good choice when you don't need the advanced pattern matching capabilities of regular expressions. For example, a trigger based on commit messages starting with fix can be achieved using a wildcard. We recommend using the pattern property to achieve this:

my_awesome_workflow
triggers:
push:
- branch: main
- commit_message:
pattern: "hello"
Alternative syntax

You can also add your wildcard pattern right next to the commit_message field: commit_message: "hello". We’ll continue to support this syntax.

Wildcards are useful to match specific, fixed values appearing in the input. We recommend using regexes are needed when multiple alternative values, negation, capturing specific groups of characters or specific character types (for example, numbers only) are needed.

To use regular expressions for a trigger condition, you need to add regex: to its value:

workflows:
deploy:
triggers:
tag:
- name:
regex: '^\d\.\d\.\d$'
pull_request:
- comment: "[workflow: deploy]"
commit_message:
regex: '.*\[workflow: deploy\].*'

Trigger componentsClick to copy link

ComponentDescriptionAccepted valuesDefault value
pull request push tagDefines the type of a trigger. The trigger conditions of a target-based trigger are children of these elements.N/AN/A
enabledA boolean property that defines if the trigger is currently active.- true - falsetrue
ComponentDescriptionDefault value
branchThe branch of the repository where code is pushed to trigger a build.*
commit_messageThe commit message to trigger a build.*
changed_filesThe path to a file or folder where changes should trigger a build.*
last_commitA boolean property that defines whether Bitrise should evaluate every commit message or changed file in a code push or only those belonging to the most recent commit.false
ComponentDescriptionDefault value
source_branchThe branch of from which the pull request is opened.*
target_branchThe branch which is the merge target of the pull request.*
labelThe pull request label.*
draft_enabledA boolean property that defines if draft pull requests trigger builds.true
commentA comment posted on a pull request.*
commit_messageA specific commit message in pushes to a pull request.*
changed_filesSpecific files that are modified in a pull request.*
ComponentDescriptionDefault value
nameThe value of the tag. Accepts a string value or a regex property.*