Skip to main content

Triggers

Cron

The cron trigger allows you to trigger a pipeline run at a scheduled time.

You can schedule a workflow to run at specific UTC times using POSIX cron syntax. Scheduled pipelines run on the latest commit on the default or base branch. The shortest interval you can run scheduled workflows is once every 1 minute.

This example triggers the pipeline Cron job every night at midnight (UTC):

trigger:
- cron:
ref: refs/heads/master
expression: "0 0 * * *"

Multiple cron entries may be specified to schedule the pipeline at different times throughout the day.

trigger:
- cron:
ref: refs/heads/master
expression: "0 0 * * *"
- cron:
ref: refs/heads/master
expression: "0 9 * * *"

This would trigger a pipeline job every night at midnight and 9am (UTC).

  • ref (required)
    Specifies the Git reference (e.g., a branch name like refs/heads/main or a tag like refs/tags/v1.0) within this repository.
    The scheduled pipeline will execute using the code from the latest commit on this specific reference at the designated time.

  • expression (required)
    Defines the schedule for the pipeline run using POSIX cron syntax. The time is specified in UTC. For example, "0 0 * * *" triggers the job daily at midnight UTC.

note

* is a special character in YAML, so you have to quote cron string, like "0 0 * * *"

tip

You can use crontab guru to help generate your cron syntax and confirm what time it will run.
To help you get started, there is also a list of crontab guru examples.

Pull Request

The pull_request trigger allows you to trigger a pipeline run when a pull request is opened/updated.

In addition to code update triggering the job, it allows users leaving a comment on the pull request that starts with [CI CHECK] to trigger the job.

This trigger is useful for validating that code builds successfully and running automated tests on pull requests before they are merged.

trigger:
- pull_request:
repo_regex: "MyOrg/my-cool-app"
source_branch_regex: "(task|feature)/(.*)"
target_branch_regex: "master"
comment:
enabled: true
message_filter_regex: "Run Tests"
  • repo_regex (optional)
    If set, the trigger only activates when a push occurs in the specified repository (e.g., "MyOrg/my-cool-app").
    If not set, it only listens for pushes in the repository where the workflow is defined. (default)
note

To ensure a consistent and predictable execution environment, if the repo field is set (i.e., the workflow is triggered by a push to a different repository), the workflow will always be executed from the default branch of the repository where the workflow is defined.

  • source_branch_regex (optional)
    A regular expression used to match the source branch name. The pipeline will only run if the source pull request branch name matches this pattern.
    If not set, the trigger applies to all branches. (default)

  • target_branch_regex (optional)
    A regular expression used to match the target branch name. The pipeline will only run if the target pull request branch name matches this pattern.
    If not set, the trigger applies to all branches. (default)

  • comment.enabled (Optional) A boolean flag to indicate if job should be triggered a on pull request comment that starts with [CI CHECK] true by default.

  • comment.message_filter_regex (optional) A regular expression used to filter which comments trigger the pipeline.

    • With filter: If message_filter_regex is specified, the pipeline will only run if the comment starts with [CI CHECK] and the text immediately following [CI CHECK].
      • If your configuration is message_filter_regex: "Run Tests", only a comment like[CI CHECK] Run Tests will trigger the pipeline.
      • Comments such as [CI CHECK] Build Project or Run Tests (without the prefix) will not activate this trigger.
    • No Filter: If message_filter_regex is omitted, any comment starting with [CI CHECK] will trigger the pipeline. (default)

Push

The push trigger allows you to trigger a pipeline run when a commit is pushed to a branch.

trigger:
- push:
repo: MyOrg/my-cool-app
branch_regex: "master"
  • repo (optional)
    If set, the trigger only activates when a push occurs in the specified repository (e.g., "MyOrg/my-cool-app").
    If not set, it only listens for pushes in the repository where the workflow is defined. (default)
note

To ensure a consistent and predictable execution environment, if the repo field is set (i.e., the workflow is triggered by a push to a different repository), the workflow will always be executed from the default branch of the repository where the workflow is defined.

  • branch_regex (optional)
    A regular expression used to match the source branch name. The pipeline will only run if the pushed branch name matches this pattern.
    If not set, the trigger applies to all branches. (default)

Examples

Example 1: Trigger on any branch in the same repository

trigger:
- push:

Runs the workflow on any push to any branch in the same repository where the workflow is defined

Example 2: Trigger only on master in the same repository

trigger:
- push:
branch_regex: "master"

Runs the workflow only when there’s a push to the master branch in the same repository.

Example 3: Trigger on any branch in another repository

trigger:
- push:
repo: MyOrg/my-cool-app

Runs the workflow on any push to any branch in the MyOrg/my-cool-app repository.

Example 4: Trigger only on master in another repository

trigger:
- push:
repo: MyOrg/my-cool-app
branch_regex: "master"

Runs the workflow only when there’s a push to the master branch in the MyOrg/my-cool-app repository.

Example 5: Trigger on task/ or feature/ branches in another repository

trigger:
- push:
repo: MyOrg/my-cool-app
branch_regex: "(feature|task)/(.*)"

Runs the workflow when there’s a push to any branch that starts with task/ or feature/ in the MyOrg/my-cool-app repository.

Multiple Push Triggers

You can define multiple push triggers in a workflow to respond to different repositories or branch patterns. Each trigger is evaluated independently.

trigger:
- push:
branch_regex: "master"
- push:
branch_regex: "release"

Pull Request (Comment)

The pull_request_comment trigger allows you to trigger a pipeline run when a comment on a pull request is made.

This is particularly useful for re-running failed jobs, triggering tests on-demand, enabling manual approvals through comments, running resource-intensive jobs only when requested, and allowing contributors to trigger builds after making review changes.

To activate this trigger, a comment must begin with the text [CI CHECK].

trigger:
- pull_request_comment:
repo_regex: "MyOrg/my-cool-app"
source_branch_regex: "(task|feature)/(.*)"
target_branch_regex: "master"
message_filter_regex: "Run Tests"
  • repo_regex (optional)
    If set, the trigger only activates when a push occurs in the specified repository (e.g., "MyOrg/my-cool-app").
    If not set, it only listens for pushes in the repository where the workflow is defined. (default)
note

To ensure a consistent and predictable execution environment, if the repo field is set (i.e., the workflow is triggered by a push to a different repository), the workflow will always be executed from the default branch of the repository where the workflow is defined.

  • source_branch_regex (optional)
    A regular expression used to match the source branch name. The pipeline will only run if the source pull request branch name matches this pattern.
    If not set, the trigger applies to all branches. (default)

  • target_branch_regex (optional)
    A regular expression used to match the target branch name. The pipeline will only run if the target pull request branch name matches this pattern.
    If not set, the trigger applies to all branches. (default)

  • message_filter_regex (optional) A regular expression used to filter which comments trigger the pipeline.

    • With filter: If message_filter_regex is specified, the pipeline will only run if the comment starts with [CI CHECK] and the text immediately following [CI CHECK].
      • If your configuration is message_filter_regex: "Run Tests", only a comment like[CI CHECK] Run Tests will trigger the pipeline.
      • Comments such as [CI CHECK] Build Project or Run Tests (without the prefix) will not activate this trigger.
    • No Filter: If message_filter_regex is omitted, any comment starting with [CI CHECK] will trigger the pipeline. (default)