How to capture test case status(Pass/Fail) in global variable

How to capture test case status(Pass/Fail) in global variable:

Details: Actually I want to retry only failed test cases, hence I need the status of failed test case to re-run again, please suggest the approach to achieve this(re-run test case if any test case failed with assertion)