Gitlab pipeline should fail if they found vulnerability in pipeline

Hi,

I have created a pipeline in GitLab and I have defined the stages as code quality, build, scan license manager.
If my pipeline triggers its scans the code and I can able to view the scan reports and the pipeline passes in all stages.
My requirement to the pipeline. If I found any vulnerability in my code my pipeline should automatically fail. Kindly guide how should I make the pipeline fail if I found a vulnerability in my code.