Run step based on which previous step failed #26969
-
I’m planning on writing a workflow which executes the unit, integration and E2E tests as separate steps. As part of this, I would like to change what artifacts are uploaded for a failed test run based on which testing step failed. Is it possible for a step to know which step failed? E.g. unit tests should upload just a summary of the unit tests, whilst the E2E tests may include screenshots of the failed tests? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @jeffersonbledsoe , You could use steps.<step id>.outcome to get the step result. And you could use if conditional in the upload artifacts step, add always() in addition to let the step to run even if previous step failed. if: always() && steps.step2.outcome == ‘failure’
|
Beta Was this translation helpful? Give feedback.
-
@yanjingzhu Works great, thanks for the help! |
Beta Was this translation helpful? Give feedback.
Hi @jeffersonbledsoe ,
You could use steps.<step id>.outcome to get the step result. And you could use if conditional in the upload artifacts step, add always() in addition to let the step to run even if previous step failed.
if: always() && steps.step2.outcome == ‘failure’