How do I ignore failed server/sonarqube uploads in Gradle

I’m using sonarqube plugin on gradle.

I see these errors in my build scripts occasionally:

One is if the project is already being analysed and the other one is when the connection breaks.
ERROR: Unable to execute Sonar
ERROR: Caused by: The project is already being analysed.

These errors make the build fail, is there a way to avoid the failure status?

One thing you might consider is designing your CI process so that this build failure doesn’t block your primary build.

I would treat the Sonar scan with integration tests and performance tests. A failure in any of these tasks should not block the primary development cycle, so don’t run them as part of the primary development cycle. Run them as separate jobs in your CI process. Report these failures, but handle them differently than the assembly of your production product, along with unit tests (failures in unit tests should always fail the primary build).