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
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).
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:
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
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