'Conditionally show approval job based on previous job?

I have a CircleCI job that runs some visual snapshot tests, if the tests fail I'd like to show an approval job to let the developer run a second job that will update the snapshot tests and push them to the PR branch.

This is my current config:

jobs:
  - visual-tests
  - update-visual-tests-approval:
      type: approval
      requires:
        - visual-tests
      # Here I'd need something to only show this (and the subsequent step)
      # only if the `visual-tests` step failed
  - update-visual-tests:
      requires:
        - update-visual-tests-approval

What are my options?



Solution 1:[1]

this will do the trick:

https://support.circleci.com/hc/en-us/articles/360043188514-How-to-Retry-a-Failed-Step-with-when-Attribute-

you will need to apply this change on the update-visual-tests-approval job.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 danny kaplunski