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
Run for a 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 the changes from that branch:
Test all changes in the repo
Buddy can act as a 'classic' CI server that will automatically test new revisions from all branches in the repository. To do that, assign the pipeline as a wildcard (*
):
Run on tag push
Upon finishing a development milestone an application usually receives a new tag. In Buddy, you can create a dedicated pipeline that will run only if a new tag was pushed to the repo:
Run for all branches except master
Buddy supports Regex which 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:
Run only the newest execution in the pipeline
By default, a pipeline cannot be undergoing more than one execution at a time. If another user triggers the same pipeline while it'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 Always run all queued executions in the pipeline settings, for example if you want to check the status of all commits on GitHub:
If the pipeline is assigned to a wildcard, then only the executions within the same branch are skipped. For example, if you have a pipeline with 1 execution on the Master branch and 3 executions on the Stage branch queued, Buddy will run the execution for Master and skip 2 executions for Stage.
Conditional executions in actions
Run on a change in the path
Pipeline actions can be run depending on the changeset in the repository. For example, if you have an action that compiles your assets, you can skip it if there were no changes in the path that requires compilation.
This option is available in the action details under More options → Trigger Condition. To activate it, select Execute on change in repository paths and provide the path(s) in the repository that Buddy should monitor for changes:
Run depending on the result of the 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:
- Add another action and check if the value of the variable is correct:
Run depending on the parameters passed on the pipeline run
For example, you can set a parameter to notify your clients about a new version on the Slack channel. Then, use trigger condition in the Slack action to check if the action should be executed or not:
Run depending on the ENV VAR value
Actions can also be run depending on the value of an Environment Variable. For example, you can define $BUDDY_EXECUTION_BRANCH
in a wildcard pipeline to run integration tests for a specific branch only.
This option is available in the action details under More options → Trigger Condition. To activate it, select Execute depending on the value of environment variable, enter the variable, and define the condition that it has to meet to run the action:
You can use Buddy's default variables, parameters defined in the Pass arguments action, and custom variables defined in the pipeline settings.
Run only for a specific branch
Create a condition using the default env var BUDDY_EXECUTION_BRANCH
:
Run only if the pipeline was executed by a specific person
Create a condition using the default env var BUDDY_INVOKER_ID
:
Run only if the commit message contains a specific phrase
Create a condition using the default env var BUDDY_EXECUTION_REVISION_MESSAGE
: