Conditional executions
Pipelines and actions can be configured to run on specific conditions. Buddy gives developers full flexibility towards what, where and when should be run, letting you cover even the most sophisticated delivery workflows.
Conditional executions in pipelines
Pipelines can be run in three trigger modes:
- On events – e.g. on a push to the selected branch.
- Manually – triggered manually by the user.
- On schedule – on a selected time interval.
Each mode lets you select the code scope in which the pipeline operates:
- Branch
- Tag
- Wildcard
- Codeless (manual and on schedule only)
All these settings combined allow you to configure pipelines for a wide variety of use cases: from manual releases to the production server, to deployments triggered by a specific phrase in the commit message. Below you can will instructions for different conditions.
Run for specific branch
This setting is most commonly used in deployment pipelines. For example, deployments to the Production server are usually made from the master branch. Assigning the pipeline to 'master' will make Buddy only upload changes from that branch:
Pipeline settings configuration
Test all changes in repo
In this use case, Buddy acts as a 'classic' CI server that automatically tests new revisions from all branches in the repository.
Configuration
- Trigger: On events
- Event: Git push
- Code scope: Wildcard
- Wildcard match:
refs/heads/*
Pipeline with wildcard trigger mode
Run on tag push
Upon finishing a development milestone, an application usually receives a new tag. In Buddy, you can create a pipeline that runs only if a new tag is created or pushed to the repo.
Configuration
- Trigger: On events
- Event: Git push / Git create branch or tag
- Code scope: Tag
Pipeline with tag trigger mode
Run for all branches except master
Buddy supports Regex that lets you create patterns for your pipelines. For example, entering (^((?!master$).)*$)
for the pattern will force the pipeline to run for all branches except the master branch.
- Trigger: On events
- Event: Git push
- Code scope: Wildcard
- Wildcard match:
(^((?!master$).)*$)
Pipeline with regex wildcard trigger mode
Run all/only newest execution in pipeline
By default, a pipeline cannot be undergoing more than one execution at a time. If another user triggers a pipeline that's already in progress, the second execution will be queued and will not begin until the first one is over. If there are more executions in the queue (for example 5), Buddy will only run the last execution (5th) and skip the previous ones (1st-4th).
You can disable it by checking Run every queued execution in the pipeline settings – for example, if you want to check the status of all commits on GitHub:
Pipeline runtime conditions
Conditional executions in actions
Run on change in path
Certain actions can be skipped if they are not used to speed up pipeline execution. In other words, if you have an action that compiles your assets, you can skip it if there were no changes in the path that requires compilation. For example upon setting
if (changeset contains "assets/")
the action or pipeline will be run only if there were changes to the assets
path in the repository.
Condition: run on change in path
text
if (changeset is not "empty")
Run depending on result of previous action
- Add a custom variable (e.g.
$RESULT
) and set it as settable. - Add a build action and enter the condition that will define the value of the variable, for example:
export RESULT=expected_value
$

- Add another action and set the condition to check if the value of the variable is correct:
if ($RESULT is "expected_value")

Run depending on parameters passed on pipeline run
The Pass Arguments action allows you to create and pass parameters as environment variables during pipeline execution. This way you change the behavior of a pipeline that's already in progress.
For example, you can set a true/false parameter asking if you want to notify your clients of a new version on the Slack channel:
Pass Arguments action settings
Then, set a condition in the Slack action to check if the answer was positive:
if ($sendNotification is "true")
Condition: run if parameter is set to true
Once triggered, the action will ask you to select the argument that will be passed to the Slack notification:
Pass arguments window
Run depending on ENV VAR value
Variables are extremely handy when you need to be precise about what you want to run and when. Here you can use Buddy's default variables, parameters defined in the Pass Params action, and your own custom variables.
Run only for specific branch
If you have a wildcard pipeline and want to run an action on changes in a specific branch (e.g. integration tests on the master branch), you can use $BUDDY_EXECUTION_BRANCH
as the condition variable in the target action:
if ($BUDDY_EXECUTION_BRANCH is "branch_name")
Condition: run if branch is master
Run only if pipeline is executed by specific person
Although Buddy features customizable permissions for pipelines, you can also use the $BUDDY_INVOKER_ID
variable to restrict access to individual users. This is especially useful for workspaces in which developers have access to all projects by default.
if ($BUDDY_INVOKER_ID is "number")
Condition: run if invoker is user #16
http://app.buddy.works/WORKSPACE_URL/profile/USER_ID
Run only if commit message contains specific phrase
The last example of variable-based conditions is listening for a keyword in the commit message. This is useful when you push some code to the repository, but don't want to trigger the deployment just yet:
if ($BUDDY_EXECUTION_REVISION_MESSAGE contains "phrase")
Condition: run if commit message contains deploy
Last modified on September 8, 2022