You can use sonarqube quality gates which can be configured to fail the build in some event. Use a webhook to bridge sonarqube and jenkins for your pipeline to ask for quality gate status. Check a method called waitForQualityGate() which in my opinion can achieve exactly the thing you want, here.