Trying to rescue a condition when previous steps are not run due to the if statement #25548
-
I want to notify to slack if the first step of the workflow succeeded, or failed. I have the following workflow, which checks if the 1st step succeeds, and if it does, it messages via slack with “success”. And if not, it messages via slack with “Something went wrong!”
But to my current knowledge, there is no way to know if the first (or an arbitrary step) has failed in the 3rd step because it can’t backtrack more that 2steps. So I’m trying to overcome that limitation by chaining the steps using the <if> and <success> and <cancelled> statements. But when I try this, the 3rd step will never be run, because if the 1st step fails, then the 2nd step’s status would be “NOT RUN(?)” and there is no current way to handle that situation. I tried using <if: !success()> which resulted with an error, which says
If there are any ways to condition a workflow with the success or failure within an arbitrary step, I would be very happy. Or just any work around for this situation is highly appreciated. Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The job status check functions ‘success(), failure()…’ only check the previous step status in the job. As a workaround, please set the ‘outputs’ for the 1st step, and check the value with ‘if’ in the behind steps. Code sample as below:
|
Beta Was this translation helpful? Give feedback.
-
Thank you very much weide-zhou! |
Beta Was this translation helpful? Give feedback.
The job status check functions ‘success(), failure()…’ only check the previous step status in the job. As a workaround, please set the ‘outputs’ for the 1st step, and check the value with ‘if’ in the behind steps. Code sample as below: