There are some options for you to use using your version of Jenkins, for older versions this Quality Gates checking functionality was done manually through scripts.
1. Quality Gate Plugin
A simple integration through of this plugin, you can configure it in few steps as shown in official documentation
2. Webhooks
From version 6.2 of Sonar this check can be done through webhooks, as shown this article
3. Shell Script
As pointed out by ansolsi Zied on this thread, you can check using the script below:
if [ "\`curl -sL -w %{http_code} http://sonar_host/api/qualitygates/project_status?projectKey=project_key -o /dev/null -S --quiet 2>&1 | jsawk -a 'return this.status'\`" == "ERROR" ];
then
exit 1;
fi;
Replacing project_key key to your Sonar registered project
In previous versions of Sonar, there was a plugin called Build Breaker Plugin, it has been discontinued and here you can read a sonar article explaining why it should no longer be used.
Thanks buddy, it worked perfectly using the Quality Gate Plugin
– Emmanuel Thadeu Souza Trindade