I’m looking for a pattern or examples of pipelines that operate as transactions with rollback. For example, we have a step that determines how many modules need to publish, then dynamically creates steps to publish 5 modules to internal maven. If module 4 fails to publish, we’d like to run a rollback on modules 1, 2 and 3.
Is there a pattern and/or examples of pipelines that determine succeeded steps on build failure and are able to run rollback steps?
We currently do not have existing patterns or examples of pipelines that specifically addresses transactions with rollback.
One way to achieve your usecase is to use conditionals in steps to check if a previous step failed and use dynamic steps to manage your rollback logic.
Thanks for the response.
So let’s say step 1 and step 2 pass and step 3 fails, we can then run a finalizer step that looks up the successful steps and runs corresponding rollback steps (e.g. step1Rollback and step2Rollback).
My question here then would be, is there a convenient way to read successful prior steps without doing API calls to retrieve the data?
Hi @saadfarooq , you can get the outcome of a step using a buildkite-agent command like this:
buildkite-agent step get "outcome" --step "key-name"
You can read more about getting the outcome of a step here `buildkite-agent step` v3 | Buildkite Documentation
Hope this helps!