We are using Azure DevOps Server 2020 and are using YAML pipelines.
Due to the lack of the auto-retry functionality in ADS 2020, i have built my own. I added a stage at the end of my pipeline which has the failed() condition. So whenever a job fails, the retry stage will kick in, which will trigger a retry build that tries the failed jobs of the provided buildId. This is working so far.
One enhancement to this that would be nice, is that i would be able to see from the build list, which builds have gone through this auto-retry. What happens is that when the auto-retry is run, the failing job will retry, but because the retry stage at the end depends on the failed job, it will also retry. Assuming the failed job succeeds the second time, the retry job will not run again and will have a final state of skipped.

What i would like to achieve is that the retry job will run on 2 conditions. Failed() and something like "has retried".
Does anyone have an idea how to achieve this? I thought about adding a tag to the build and condition on that, but i dont think that is possible. I could add a variable to the pipeline the first time im in the retry stage, but i dont think that variable is available the second round.
Is there any value i could condition on that could help me identify one of the jobs in the pipeline had a second attempt?
Solution: Thanks to the comments made by Bright, i have configured the following condition on my final stage
condition: or(failed(), gt(variables['System.StageAttempt'], 1))

