# How to quickly in one step determine if you need to run the rest

**URL:** <https://forum.buildkite.community/t/how-to-quickly-in-one-step-determine-if-you-need-to-run-the-rest/2822>\
**Category:** Pipelines\
**Created:** [April 5, 2023, 11:47pm UTC](https://forum.buildkite.community/t/how-to-quickly-in-one-step-determine-if-you-need-to-run-the-rest/2822 "2023-04-05T23:47:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![js-cb](https://avatars.discourse-cdn.com/v4/letter/j/8797f3/32.png) [@js-cb](https://forum.buildkite.community/u/js-cb)\
**Post date:** [April 5, 2023, 11:47pm UTC](https://forum.buildkite.community/t/how-to-quickly-in-one-step-determine-if-you-need-to-run-the-rest/2822/1 "2023-04-05T23:47:21Z")

</div>

we have a lengthy pipeline. but we also some of the files which don’t require any build/test. What is the best way to determine something in step1 and then bypass the rest of the steps?

Is conditional the way to go? Can i make `groups` run or not run conditionally? Any other methods? thanks

---

<div class="post-metadata">

**Author:** ![james.s](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/james.s/32/1305_2.png) [@james.s](https://forum.buildkite.community/u/james.s)\
**Post date:** [April 5, 2023, 11:59pm UTC](https://forum.buildkite.community/t/how-to-quickly-in-one-step-determine-if-you-need-to-run-the-rest/2822/2 "2023-04-05T23:59:35Z")

</div>

Hey @js-cb!

Thanks for reaching out 👋

Conditionals/groups can definitely be used - you could also combine that with the Buildkite agent’s [outcome](https://buildkite.com/docs/pipelines/conditionals#conditionals-in-steps) functionality to check on the outcome of step1 (either will be passed/hard\_failed/soft\_failed) to then determine what your pipeline does post the check (dynamic upload/more steps etc).

Hope this helps!

---

<div class="post-metadata">

**Author:** ![js-cb](https://avatars.discourse-cdn.com/v4/letter/j/8797f3/32.png) [@js-cb](https://forum.buildkite.community/u/js-cb)\
**Post date:** [April 6, 2023, 1:16am UTC](https://forum.buildkite.community/t/how-to-quickly-in-one-step-determine-if-you-need-to-run-the-rest/2822/3 "2023-04-06T01:16:54Z")

</div>

> [@james.s](#):
>
> heck on the outcome of step1 (either will be passed/hard\_failed/soft\_failed) to then determine what your pipeline does post the check

great! thanks James

---

<div class="post-metadata">

**Author:** ![james.s](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/james.s/32/1305_2.png) [@james.s](https://forum.buildkite.community/u/james.s)\
**Post date:** [April 6, 2023, 1:19am UTC](https://forum.buildkite.community/t/how-to-quickly-in-one-step-determine-if-you-need-to-run-the-rest/2822/4 "2023-04-06T01:19:19Z")

</div>

No worries @js-cb!

Please reach out if anything else is needed!

---

<div class="post-metadata">

**Author:** ![js-cb](https://avatars.discourse-cdn.com/v4/letter/j/8797f3/32.png) [@js-cb](https://forum.buildkite.community/u/js-cb)\
**Post date:** [April 6, 2023, 1:22am UTC](https://forum.buildkite.community/t/how-to-quickly-in-one-step-determine-if-you-need-to-run-the-rest/2822/5 "2023-04-06T01:22:45Z")

</div>

The `outcome` is not very desirable because I have to get down to the command level for every single step and add that  
Group conditional is a good route for me. Can I make my initial step define an ENV var (based on a full build being required or not) and then use that in the `if` attribute of the next group?

---

<div class="post-metadata">

**Author:** ![james.s](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/james.s/32/1305_2.png) [@james.s](https://forum.buildkite.community/u/james.s)\
**Post date:** [April 6, 2023, 2:04am UTC](https://forum.buildkite.community/t/how-to-quickly-in-one-step-determine-if-you-need-to-run-the-rest/2822/6 "2023-04-06T02:04:40Z")

</div>

You can definitely use an environment variable to pass on to that initial step in an `if` conditional: you’ll need to interpolate it at runtime with `SS` or `\S` (for example `$$EXAMPLE_VAR == "foo"`

You can also use the `outcome` functionality with group keys if it assists also: for example should you have a group with a label `group1` - you can get its outcome just like a step:

```auto
steps:
  - group: "Group example"
    key: "group1"
    steps:
      - label: ":wave: First wave"
        key: wave_1
        command: "echo 'Hello - first!'"
      - label: ":wave: Second wave"
        key: wave_2
        command: "echo 'Hello - second!'"
        depends_on:
        - wave_1
  - command: |
      if [$$(buildkite-agent step get "outcome" --step "group1") == "passed"]; then
        buildkite-agent pipeline upload buildkite-example.yml
      fi
    depends_on:
    - group1

```

Hope this helps!

---

<div class="post-metadata">

**Author:** ![js-cb](https://avatars.discourse-cdn.com/v4/letter/j/8797f3/32.png) [@js-cb](https://forum.buildkite.community/u/js-cb)\
**Post date:** [April 6, 2023, 2:18am UTC](https://forum.buildkite.community/t/how-to-quickly-in-one-step-determine-if-you-need-to-run-the-rest/2822/7 "2023-04-06T02:18:00Z")

</div>

> [@james.s](#):
>
> `buildkite-agent pipeline upload buildkite-example.yml`

ok this is going to be very helpful:  
`buildkite-agent pipeline upload buildkite-example.yml`

---

<div class="post-metadata">

**Author:** ![james.s](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/james.s/32/1305_2.png) [@james.s](https://forum.buildkite.community/u/james.s)\
**Post date:** [April 6, 2023, 2:24am UTC](https://forum.buildkite.community/t/how-to-quickly-in-one-step-determine-if-you-need-to-run-the-rest/2822/8 "2023-04-06T02:24:30Z")

</div>

Happy to hear!

Its that dynamic upload in the recommendation that holds power in the conditional: you could further upload more groups/different pipelines based on outcomes, which then you could repeat this for various pipelines and such 👍
