Mvn sonar results in CI process

Hi All,
I use sonarcube version 7.9.1, sonar scanner: org.sonarsource.scanner.maven:sonar-maven-plugin:

I use sonar in CI process (Jenkins).
If the project doesn’t stand on my quality gate the process should stop.
After the command mvn:sonar run successfully I check by the rest api: api/qualitygates/project_status?projectKey=${PROJECT_KEY} what is the project status, and decide if i can continue with the process.

The problem: The data sent by the command mvn sonar is still run as background task in the sonarcube and i get the previous status .

Is there a way to know background task is running?
Or maybe other solution?

I don’t want to stop the CI process to X minutes, because the time is important for me.

Hi Osnat,

The SonarScanner for Jenkins plugin is the answer to your prayers. It adds support for making your pipeline script pause until the quality gate is calculated for the project. This is done by making the pipeline pause until a webhook is called from SonarQube to Jenkins that lets it know the pipeline may continue.

Thank you, Jeff, for your answer.
SonarScanner for jenkins has uncomfortable way to support multi modules project.
My project has a lot of modules, and i don’t want to duplicate the list of the modules from the parent pom.
so, i use the simple command - mvn sonar.

other ideas? or maybe solution to the multi modules in sonarScanner?