Conditional steps if-else without code duplication

Hi, is there a way to emulate an if-else statement for conditional steps?
Currently, is it possible to do that by mirroring the conditions like such:

    steps: 
      - when:
          condition: << parameters.win >>
          steps:
            - run: echo "You won!"
      - when:
          condition:
              not: << parameters.win >> 
          steps:
            - run: echo "You lost!"

But as you see, it’s code duplication, and will make the config hard to read and large.
Is there a something similar to this?

    steps: 
      - when:
          condition: << parameters.win >>
          steps:
             - run: echo "You won!"
          else: 
               steps:
                 - run: echo "You lost!"

Depending on the situation, you may be able to do your conditionals with bash rather than YAML. In this specific example for instance:

- run:
  environment:
    WIN_RESULT: <<parameters.win>>
  command: | 
    if [ $WIN_RESULT = 1 ]; then
      echo "You Won!"
    else
      echo "You Lose!"
    fi

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.