Conditioning a step on the EXIT_CODE of the previous step

​Hi Jaganiku and welcome!

@xiaket is correct because the value is not known when the build is created.

The way you could achieve this would be to use the buildkite-agent steps get command to grab the step outcome and do a dynamic upload to create the next step(s); you could do it in the step or in a script. Here is one that I created in the Buildkite YAML editor for an example:

steps:
  - label: 'Step 1'
    command: "true"
    key: 'one'
  
  - wait:
    continue_on_failure: true
    
  - label: 'Step 2'
    command: |
      if [ $$(buildkite-agent step get "outcome" --step "one") == "passed" ]; then
        buildkite-agent pipeline upload .buildkite/my-steps.yml
      fi
1 Like