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

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

Hey @js-cb!

Thanks for reaching out :wave:

Conditionals/groups can definitely be used - you could also combine that with the Buildkite agent’s outcome 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!

1 Like

great! thanks James

No worries @js-cb!

Please reach out if anything else is needed!

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?

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:

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

Hope this helps!

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

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 :+1: