Retry logic for sonarqube gradle task

We are using sonarqube gradle task to collect Java CC numbers and publish them to sonar.

My problem statement is that I want to re execute sonarqube gradle task in case some sonar server connection refused exception occurs while executing sonarqube gradle task.

Currently, we are using sonarqube 4.5.7 and gradle 1.12.

As of now our build job running on jenkins stop abruptly after encountering the error.

Please guide how to re execute the same task again when any failure is encountered