Creating Mutually exclusive steps

There are some steps that if triggered should block others. This will allow some kind of branching. Let’s say that my pipeline is building a cake. One step could be “eat the cake” and the other “throw the cake in the trash”. Both steps are very useful. But, I would like to avoid somebody trying to eat the cake after throwing it in the trash.

We could just point to the other step and say that after successfully running that step we should not be able to run some other steps. It would be very similar to the “depends_on” attribute, but working in the reverse.

steps:
    - block: Build the Cake
    - block: Eat the Cake
      depends_on: Build the Cake
      if_not: Throw the Cake in the Trash
    - block: Throw the Cake in the Trash
      depends_on: Build the Cake
      if_not: Eat the Cake

image

Hi @thiagomata!

Welcome to our community!

You can store the outcome of the block step in a metadata and then have another step that checks the metadata and dynamically uploads more steps. This way, only the steps that need to be run are added dynamically into the pipeline.

But if you know whether to ‘eat_the_cake’ or ‘throw_the_cake’ during the pipeline upload time (not during the run time), then you can use the ‘if’ attribute to conditionally run a step. ‘If’ attribute values are evaluated at the upload time, so it needs to be known at the time of uploading.

Hope this helps! Let us know for any questions.

Best,
Nithya

1 Like