Action Loop

The Action Loop feature allows you to automatically iterate actions based on a matrix of variable value combinations. This lets you run the same action multiple times with different parameters without having to define each action manually.

Hint
For automating entire pipelines with multiple runs, see Pipeline Loop.

GUI configuration

In the action settings, find the RUN STRATEGY section. You'll see two options: Parallel actions and Loop. Select Loop to configure action iteration. A configuration window will appear where you can select already defined variables or add new ones.

Image loading...Action editor with RUN STRATEGY section showing Loop option

How does action loop work?

Action Loops operate on the basis of a combination matrix, they generate all possible combinations of variable values and run the action separately for each combination.

YAML configuration

Action Loops can also be configured directly in the buddy.yml file using the loop field:

yaml
- pipeline: testloop-single fail_on_prepare_env_warning: true actions: - action: "Test loop" type: BUILD loop: - environment docker_image_name: buddy/localshell docker_image_tag: ubuntu_24.04 execute_commands: - "echo \"Testing: $environment\"" shell: BASH variables: - key: environment value: "staging,production"

Multi-variable example:

yaml
- pipeline: testloop_multiple fail_on_prepare_env_warning: true actions: - action: Test multiple variables loop type: BUILD loop: - whos - animal docker_image_name: buddy/localshell docker_image_tag: ubuntu_24.04 execute_commands: - "echo \"Owner: $whos, Pet: $animal\"" shell: BASH variables: - key: animal value: "cat,dog" - key: whos value: "my,your"

Image loading...View action with set loops

Result: 4 runs (2×2)

  • Run 1: echo "Owner: my, Pet: cat"
  • Run 2: echo "Owner: my, Pet: dog"
  • Run 3: echo "Owner: your, Pet: cat"
  • Run 4: echo "Owner: your, Pet: dog"

Image loading...Detail Run action with loops

Action loop configuration

The loop field accepts an array of variable names that should be used for iteration:

yaml
loop: - variable1 - variable2 - variable3
Hint
You can find more information about the YAML syntax for the action loop in the documentation: YAML Schema – Action loop.

Practical examples

Multi-region deployment

yaml
- pipeline: "multi-region-deployment" actions: - action: "Deploy to region" type: "BUILD" docker_image_name: "buddy/localshell" execute_commands: - "echo \"Deploying to $region with $config\"" variables: - key: "region" value: "us-east,eu-west,asia-pacific" type: "VAR" - key: "config" value: "dev,prod" type: "VAR" loop: - "region" - "config"

Image loading...Action Loop - configuration example

Multi-platform build

yaml
- pipeline: "multi-platform-build" actions: - action: "Build for platform" type: "BUILD" docker_image_name: "golang:1.19" execute_commands: - "GOOS=$os GOARCH=$arch go build -o app-$os-$arch" variables: - key: "os" value: "linux,windows,darwin" type: "VAR" - key: "arch" value: "amd64,arm64" type: "VAR" loop: - "os" - "arch"

Summary

Action Loop is an option for automating repetitive tasks. Instead of manually duplicating actions, you can use a single action with a loop that automatically generates the entire combination matrix.

Warning
Remember the resource limitations and the number of combinations that may be generated.

API

The action loop is also available through the REST API. You can use the loop parameter when creating an action:

Last modified on Nov 18, 2025