How can prevent to execute deploy in prod if test stage fail?


I have a pipeline thats works fine in branches, but I detected one behavior that I would like fix in master.

I have a condition that you can’t execute deploy prod until deploy stage successfully.
But I’ve found an issue, because when the tests in master are failing I can deploy in prod… and I shouldn’t.

Can you give a hand to avoid this behavior, and when prod tests or deploy stage are not OK not be able to deploy in prod?

This is my code of my pipeline

I tried with
needs: [“testing_maven_prod”,“deploy_staging”] or needs: [“test”,“deploy_staging”] but didn’t work me

Thank you very much