# Creating Mutually exclusive steps

**URL:** https://forum.buildkite.community/t/creating-mutually-exclusive-steps/1889
**Category:** Features Requests
**Created:** [February 1, 2022, 4:58am UTC](https://forum.buildkite.community/t/creating-mutually-exclusive-steps/1889 "2022-02-01T04:58:43Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![thiagomata](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/thiagomata/32/1037_2.png) [@thiagomata](https://forum.buildkite.community/u/thiagomata)
#### Post date: [February 1, 2022, 4:58am UTC](https://forum.buildkite.community/t/creating-mutually-exclusive-steps/1889/1 "2022-02-01T04:58:43Z")

</div>

There are some steps that if triggered should block others. This will allow some kind of branching. Let’s say that my pipeline is building a cake. One step could be “eat the cake” and the other “throw the cake in the trash”. Both steps are very useful. But, I would like to avoid somebody trying to eat the cake after throwing it in the trash.

We could just point to the other step and say that after successfully running that step we should not be able to run some other steps. It would be very similar to the “depends\_on” attribute, but working in the reverse.

```auto
steps:
    - block: Build the Cake
    - block: Eat the Cake
      depends_on: Build the Cake
      if_not: Throw the Cake in the Trash
    - block: Throw the Cake in the Trash
      depends_on: Build the Cake
      if_not: Eat the Cake

```

![image](https://us1.discourse-cdn.com/flex016/uploads/buildkite1/original/2X/8/83fae1add94fc480bc939acc2b5556a72155b7f5.png)

---

<div class="post-metadata">

### Author: ![anon4496704](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@anon4496704](https://forum.buildkite.community/u/anon4496704)
#### Post date: [February 1, 2022, 6:10am UTC](https://forum.buildkite.community/t/creating-mutually-exclusive-steps/1889/2 "2022-02-01T06:10:26Z")

</div>

Hi @thiagomata!

Welcome to our community!

You can store the outcome of the block step in a [metadata](https://buildkite.com/docs/agent/v3/cli-meta-data#navicon) and then have another step that checks the metadata and dynamically uploads more steps. This way, only the steps that need to be run are added dynamically into the pipeline.

But if you know whether to ‘eat\_the\_cake’ or ‘throw\_the\_cake’ during the pipeline upload time (not during the run time), then you can use the [‘if’ attribute](https://buildkite.com/docs/pipelines/conditionals#conditionals-in-steps) to conditionally run a step. ‘If’ attribute values are evaluated at the upload time, so it needs to be known at the time of uploading.

Hope this helps! Let us know for any questions.

Best,  
Nithya
