# Step bundles

Step bundles allow you to group multiple Steps into a single unit. With Step bundles, you can reuse Steps and sequences of Steps without manually copying and pasting from a YAML configuration file.

Step bundles are configured with a root level entity called `step_bundles`. You can insert Step bundles into any Workflow. Unlike utility Workflows and [Workflow chaining](/bitrise-ci/workflows-and-pipelines/workflows/managing-workflows#chaining-workflows-together), Step Bundles can be placed anywhere in a Workflow.

When running a build, each Step within the bundle will run at the position the bundle is inserted.

## Creating a Step bundle

**Workflow Editor**

1. Open the Workflow Editor.
1. On the left, select **Step bundles**.
1. Click **Create Step bundle** if you don't have any bundles.

   If you already have at least one Step bundle, open the dropdown menu in the middle and click **Create Step bundle**.

   ![create-step-bundle.png](/img/_paligo/uuid-955d7e00-c03b-fa26-f239-dcf2f2b2708a.png)
1. In the dialog, provide an ID for your bundle.

   ![Create Step bundle dialog](/img/workflows-and-pipelines/2026-07-06-create-step-bundle-dialog.png)
1. If you have existing Step bundles, you can select one from the dropdown menu: your new Step bundle will be a copy of the existing one.
1. When done, click **Create Step bundle**.
1. Add your first Step by clicking **Add Step or Step bundle**.

   Adding a Step bundle within another Step bundle is called nesting: [Nested Step bundles](/bitrise-ci/workflows-and-pipelines/steps/step-bundles#nested-step-bundles).
1. Add additional Steps or bundles by hovering above or under an already added Step or bundle and clicking on the plus sign.
1. Configure new bundle inputs under the **Configuration** tab by clicking **+ Add input**. In the **New bundle input**dialog you can define input variables to manage multiple Steps within a bundle. Reference their keys in Steps and assign custom values for each Workflow.

   ![bundleinput.png](/img/_paligo/uuid-b51f2636-2f9d-89c2-595e-db6ab80d5416.png)

**Configuration YAML**

1. [Open the configuration YAML of your project](/bitrise-ci/configure-builds/configuration-yaml/editing-an-app-s-bitrise-yml-file).
1. Add a `step_bundles` entity to the top level of the YAML file and give it a name. You will refer to the bundle by this name.

   ```yaml
   format_version: 11
   step_bundles:
     install_deps:
   ```
1. Add a `steps` property under your bundle and add the Steps you want to run. You can [reference Steps](/bitrise-ci/references/steps-reference/step-reference-id-format) here the same way as in a Workflow.

   In this example, we add the *restore-cache* Step and an `npm` Step.

   ```yaml
   format_version: 11
   step_bundles:
     install_deps:
       steps:
       - restore-cache@1: {}
       - npm@1: {}
   ```
1. Add your Step bundle to an existing Workflow. The syntax works like this: `bundle::<bundle-name>`.

   ```yaml
   workflows:
     ci:
       steps:
       - git-clone@8.1: {}
       - bundle::install_deps: {}
       - deploy-to-bitrise-io@2: {}
   ```

## Creating a Step bundle based on a utility Workflow

You can create a Step bundle based on a [utility Workflow](/bitrise-ci/workflows-and-pipelines/workflows/managing-workflows#utility-workflows). The bundle will contain all the Steps that were part of the utility Workflow. But unlike a utility Workflow, you can place the Step bundle anywhere within another Workflow.

1. Open the Workflow Editor.
1. On the left, select **Step bundles**.
1. From the **Based on** dropdown menu, choose a utility Workflow.

   ![Screenshot_2025-03-25_at_09_59_54.png](/img/_paligo/uuid-8b6d8a17-8028-3064-a48d-9a43b0328391.png)
1. Click **Create Step bundle**.

## Naming Step bundle instances

You can add optional metadata fields to Step bundle instances to make your Workflow configs and build logs easier to read in Workflows.

:::note[Step bundle instance]

Step bundles are reusable config blocks - you define them once and can use them (instantiate them) across Workflows or in the same Workflow.

:::

You can set three optional metadata fields: **title**, **summary** and **description** in your Step bundle. These attributes override the generic information from the bundle's definition for that specific instance only, giving you granular control over how it's displayed in a particular Workflow. If you use these attributes, you don't need to add comments to Step bundles to distinguish two instances from each other.

A Step bundle instance can include:

- **title**: a human-readable name for this specific usage.
- **summary**: a brief description.
- **description**: detailed information about what this instance does.

![stepbundleinstance.png](/img/_paligo/uuid-9cf7ca34-d643-d13c-d241-42cefd6dc847.png)

These fields show up in the Bitrise UI and build logs, making it immediately clear what each instance is doing.

```yaml
- step-bundle-id:
    title: "A clear, human-readable title for this instance"
    summary: "A short summary of what this instance does."
    description: "A more detailed markdown-supported description if needed."
    inputs:
      - ...
```

**Additional attributes for Step bundle instances**

Let's say you have a Step bundle defined with the ID `run-my-tests` that builds and tests a specific scheme. You want to use it twice in your primary Workflow: once for unit tests on an iPhone simulator, and again for UI tests on an iPad simulator.

```yaml
workflows:
  primary:
    steps:
    - run-my-tests:
        title: "Run unit tests on iPhone"
        summary: Runs the UnitTests test plan.
        inputs:
        - scheme: "MyApp"
        - destination: "platform=iOS Simulator,name=iPhone 14"
        - test_plan: "UnitTests"
    - run-my-tests:
        title: "Run UI tests on iPad"
        summary: Runs the UITests test plan.
        inputs:
        - scheme: "MyApp"
        - destination: "platform=iOS Simulator,name=iPad Pro (12.9-inch)"
        - test_plan: "UITests"
```

The build log and Workflow editor now displays `"Run unit tests on iPhone"` and `"Run UI tests on iPad"` as the Step titles. If the UI tests fail, you'll know immediately without having to inspect the logs.

## Nested Step bundles

Step bundles allow nesting: you can add a Step bundle within another Step bundle. This allows you to create large, complex configurations with easily replaceable parts. You can add as many Step bundles within another Step bundles as you want.

**Workflow Editor**

1. Open the Workflow Editor.
1. On the left, select **Step bundles**.
1. Select a Step bundle from the dropdown menu in the middle.
1. If it's an empty bundle, click **Add Step or Step bundle**.

   If the bundle already has Steps in it, hover between Steps and click the plus sign.

   ![add-bundle-to-bundle.png](/img/_paligo/uuid-e4db471e-3219-872f-8c6f-7aa194b7f156.png)
1. In the dialog, go to the **Step bundle** tab.

   ![bundle-tab.png](/img/_paligo/uuid-68c17140-7ed7-eae8-4101-12d403bee8e4.png)
1. Select a bundle to add it to the original bundle.
1. Use drag-and-drop to move it within the bundle.
1. When done, click **Save changes**

**Configuration YAML**

1. In the configuration YAML file, define the Step bundle you want to nest within a `step_bundles` property.

   ```yaml
   step_bundles:
     initialize:
       steps:
         - activate-ssh-key: {}
         - git-clone: {}
   ```
1. Nest this bundle within another one by using the `bundles` property.

   ```yaml
   step_bundles:
     initialize:
       steps:
         - activate-ssh-key: {}
         - git-clone: {}
     deploy_bundle:
       steps:
         - bundle::initialize: {}
         - deploy-to-bitrise-io: {}
   ```

## Step bundle inputs

In any Step bundle, a list of inputs can be defined under the `inputs` key. These are the only inputs you can set for a Step bundle: you can't define additional inputs outside the bundle definition.

You can, however, set values for the predefined inputs of a Step bundle outside the bundle definition: [Configuring Step bundle inputs](#configuring-step-bundle-inputs).

Step bundle inputs share the same model as Step inputs. You can read more about Step inputs and their format: [Step inputs reference](/bitrise-ci/references/steps-reference/step-inputs-reference).

1. In your configuration YAML file, add the `inputs` property to your Step bundle.

   ```yaml
   format_version: 11
   step_bundles:
     install_deps:
       inputs:
   ```
1. Under `inputs`, add key-value pairs that will be used for Step inputs.

   ```yaml
   format_version: 11
   step_bundles:
     install_deps:
       inputs:     
       - cache_key: "npm-cache-{{ checksum "package-lock.json" }}"
       - npm_command: install
   ```
1. Add the keys to the appropriate Step inputs.

   In our example, we configured default inputs for the `key` input of the `restore-cache` Step and the `command` input of the `npm` Step.

   ```yaml
   format_version: 11
   step_bundles:
     install_deps:
       inputs:     
       - cache_key: "npm-cache-{{ checksum "package-lock.json" }}"
       - npm_command: install
       steps:
       - restore-cache@1:
           inputs:
           - key: $cache_key
       - npm@1: {}
           inputs: 
           - command: $npm_command
   ```

## Configuring Step bundle inputs

You define Step bundle inputs in the Step bundle definition and you can't add new inputs outside the definition.

You can set new values for Step bundle inputs defined in the Step bundle in the Step list of the Workflow:

1. In your configuration YAML file, find your Workflow and the Step bundle in its `steps` list.
1. Add an `inputs` property where your Step bundle is referenced, and add a key-value pair to it.

   In this example, we set a new value of the `cache_key` input instead of its default value defined in the Step bundle. When the Workflow runs, the `restore-cache` Step will use the `npm-cache` value instead of `npm-cache-{{ checksum "package-lock.json" }}`.

   ```yaml
   format_version: 11
   step_bundles:
     install_deps:
       inputs:     
       - cache_key: "npm-cache-{{ checksum "package-lock.json" }}"
       - npm_command: install
       steps:
       - restore-cache@1:
           inputs:
           - key: $cache_key
       - npm@1:
           inputs: 
           - command: $npm_command
   workflows:
     ci:
       steps:
       - git-clone@8: {}
       - bundle::install_deps:
           inputs:
           - cache_key: "npm-cache"
       - deploy-to-bitrise-io@2: {}
   ```

## Step bundle outputs

Steps can generate output variables. When Steps are included in a Step bundle, their output variables are available to all Steps in the Workflow after the Step bundle.

For example, if the Step bundle used in the Workflow uses the `xcode-archive` Step, the next Steps after the bundle will have access to the BITRISE_IPA_PATH output variable which is exposed by the Step.

## Step Bundle conditional execution with run_if

Using `run_if` condition with Step bundles allows you to conditionally execute entire bundles based on Environment Variables or other criteria. When you apply `run_if` directly to Step bundle calls in your workflow, the condition is evaluated before the bundle executes. If it evaluates to false, the entire bundle and all its Steps are skipped.

The `run_if` syntax works the same as it does for individual Steps. All the `run_if` [template expressions and custom template functions](/bitrise-ci/workflows-and-pipelines/steps/enabling-or-disabling-a-step-conditionally#examples-of-run_if-expressions), for example, `getenv`, `enveq`, and `envcontain` are supported for Steps.

**Skip deployment bundles for draft PRs**

In this example, the `deploy-to-staging` bundle would run only if the PR is not a draft PR. Similarly, the `notify-slack` bundle would run only if it is a successful build.

```yaml
workflows:
  deploy:
    steps:
      - bundle::build-and-test: {}
      - bundle::deploy-to-staging:
          run_if: '{{ not (envcontain "BITRISE_GIT_MESSAGE" "[draft]") }}'
      - bundle::notify-slack:
          run_if: '{{ not .IsBuildFailed }}'
```

1. Open your project's Workflow Editor.
1. Click **Step bundles** on the left.
1. Select the **Configuration** tab and enter a value under **Additional run conditions**.

   ![2025_08_15_step_bundle_conditional_execution_runif.png](/img/_paligo/uuid-d84d9f1d-68d7-2706-a7cb-b2023ffe96a5.png)

You can specify a `run_if` in the definition or in the Step bundle instance as well:

- When the `run_if` is in the definition, then it serves as the default run_if for all instances.
- When the `run_if` is in the instance, it overrides the definition, and that single instance will have the `run_if`.

  If a Step bundle is usually executed conditionally, it is better to define `run_if` on the definition, so that all instances will get the sensible default `run_if` . Like a repo clone and setup bundle that usually only make sense in a CI environment (that's why the git-clone Step itself has a `run_if: .IsCI`).

Learn more about how to [enable/disable and set conditions for a Step](/bitrise-ci/workflows-and-pipelines/steps/enabling-or-disabling-a-step-conditionally#examples-of-run_if-expressions) with `run_if` expressions.

### Migration

If you currently have identical `run_if` conditions on multiple Steps within a bundle, here is how you can streamline your workflow with `run_if` on Step bundles.

Before:

```yaml
workflows:
  test:
    steps:
      - bundle::my-test-suite: {}
step_bundles:
  my-test-suite:
    steps:
      - script:
          run_if: '{{ enveq "RUN_TESTS" "true" }}'
          # ...
      - gradle-runner:
          run_if: '{{ enveq "RUN_TESTS" "true" }}'
          # ...
      - deploy-to-bitrise-io:
          run_if: '{{ enveq "RUN_TESTS" "true" }}'
          # ...
```

After:

```yaml
workflows:
  test:
    steps:
      - bundle::my-test-suite:
          run_if: '{{ enveq "RUN_TESTS" "true" }}'
step_bundles:
  my-test-suite:
    steps:
      - script:
          # ...
      - gradle-runner:
          # ...
      - deploy-to-bitrise-io:
          # ...
```
