# Batch together two steps

**URL:** <https://forum.buildkite.community/t/batch-together-two-steps/1510>\
**Category:** General\
**Created:** [March 29, 2021, 11:21pm UTC](https://forum.buildkite.community/t/batch-together-two-steps/1510 "2021-03-29T23:21:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![yeswecan95](https://avatars.discourse-cdn.com/v4/letter/y/898d66/32.png) [@yeswecan95](https://forum.buildkite.community/u/yeswecan95)\
**Post date:** [March 29, 2021, 11:21pm UTC](https://forum.buildkite.community/t/batch-together-two-steps/1510/1 "2021-03-29T23:21:35Z")

</div>

Is there anyway to watch batch together two steps → I want a trigger step and a command step to fire off asynchronously but the command step should wait on the trigger step to finish.

Is there any way to batch these two steps together?

The rest of the pipeline should continue without waiting on these.

---

<div class="post-metadata">

**Author:** ![sj26](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/sj26/32/17_2.png) [@sj26](https://forum.buildkite.community/u/sj26)\
**Post date:** [March 30, 2021, 12:49am UTC](https://forum.buildkite.community/t/batch-together-two-steps/1510/2 "2021-03-30T00:49:20Z")

</div>

Sorry @yeswecan95, I’m not sure what you’re trying to do. Could you help with an example?

You can have the command step depend on the trigger step and so wait for it to finish, or you can have them run at the same time. I’m not sure what waiting on another step to finish means if you also want them to run at the same time?

---

<div class="post-metadata">

**Author:** ![yeswecan95](https://avatars.discourse-cdn.com/v4/letter/y/898d66/32.png) [@yeswecan95](https://forum.buildkite.community/u/yeswecan95)\
**Post date:** [March 30, 2021, 3:19pm UTC](https://forum.buildkite.community/t/batch-together-two-steps/1510/3 "2021-03-30T15:19:22Z")

</div>

@sj26

Let’s say I have a pipeline running → I want to run an async command x somewhere in this pipeline. And, if x finishes, I want to run a command y. If x does not finish, I do not want to run command y. The remainder of the pipeline should work as normal. X is a trigger step and y is a command step. Is this possible without having to create a new pipeline for x and y?

---

<div class="post-metadata">

**Author:** ![sj26](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/sj26/32/17_2.png) [@sj26](https://forum.buildkite.community/u/sj26)\
**Post date:** [March 30, 2021, 11:58pm UTC](https://forum.buildkite.community/t/batch-together-two-steps/1510/4 "2021-03-30T23:58:23Z")

</div>

Sounds like you might want step dependencies:

> **[Managing Step Dependencies](https://buildkite.com/docs/pipelines/dependencies)**
>
> All steps in pipelines have implicit dependencies, often managed with wait and block steps. To manually change the dependency structure of your steps, you can define explicit dependencies with the depends\_on attribute.

Something like this:

```auto
steps:
- command: will always run

- trigger: some-pipeline
  key: some-pipeline-trigger

- command: only-after-trigger
  depends_on: some-pipeline-trigger

- command: will also always run

```

The first and last command will always run immediately, and so will the trigger. The middle command will only run after the triggered build has passed. Is that kinda what you’re after?

---

<div class="post-metadata">

**Author:** ![yeswecan95](https://avatars.discourse-cdn.com/v4/letter/y/898d66/32.png) [@yeswecan95](https://forum.buildkite.community/u/yeswecan95)\
**Post date:** [March 31, 2021, 1:34am UTC](https://forum.buildkite.community/t/batch-together-two-steps/1510/5 "2021-03-31T01:34:39Z")

</div>

@sj26! yes – but i want the trigger command to be async.

---

<div class="post-metadata">

**Author:** ![sj26](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/sj26/32/17_2.png) [@sj26](https://forum.buildkite.community/u/sj26)\
**Post date:** [March 31, 2021, 3:45am UTC](https://forum.buildkite.community/t/batch-together-two-steps/1510/6 "2021-03-31T03:45:12Z")

</div>

You can add `async: true` to the trigger if you like! The only difference that will make is whether the pipeline waits fo the triggered build to complete before running the subsequent command or if it proceeds immediately once the triggered build has been created.

---

<div class="post-metadata">

**Author:** ![yeswecan95](https://avatars.discourse-cdn.com/v4/letter/y/898d66/32.png) [@yeswecan95](https://forum.buildkite.community/u/yeswecan95)\
**Post date:** [March 31, 2021, 4:49am UTC](https://forum.buildkite.community/t/batch-together-two-steps/1510/7 "2021-03-31T04:49:34Z")

</div>

@sj26 sorry let me explain –

lets say our pipeline is currently, x, y, z, w

i want z to only trigger after y but i want y, z together to be asynchronous. E.g. it goes x,  
(async) y-\>z, w but z should only trigger if y completes.

is this possible?

---

<div class="post-metadata">

**Author:** ![sj26](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/sj26/32/17_2.png) [@sj26](https://forum.buildkite.community/u/sj26)\
**Post date:** [March 31, 2021, 11:19pm UTC](https://forum.buildkite.community/t/batch-together-two-steps/1510/8 "2021-03-31T23:19:38Z")

</div>

I’m still not sure I’m following what you’re trying to do, but it sounds like you might want to use step dependencies:

> **[Managing Step Dependencies](https://buildkite.com/docs/pipelines/dependencies)**
>
> All steps in pipelines have implicit dependencies, often managed with wait and block steps. To manually change the dependency structure of your steps, you can define explicit dependencies with the depends\_on attribute.

You can explicitly say which steps should depend on other steps.

Something like:

```auto
steps:
- command: x
  key: x
- trigger: y
  key: y
- command: z
  key: z
  depends_on: y
- command: w
  key: w

```
