SonarQube issue list is not published immediately after the SonarScanner analysis

Must-share information (formatted with Markdown):

  • SonarScanner for MSBuild 5.13

  • Data Center Edition Version 9.9.1 (build 69595)

  • I am trying to assign a new issue to a specific user.

  • Wrote a tool which will query the issues after a specific date and do the assignment.
    ** I am running a task in the build pipeline after SonarScanner is completed. This task will fetch the issues created after a specific date and assign to a user. **
    ** I observed while doing the query, it returns all the issues which was published earlier, but not in the current analysis **
    ** For example, TFS shows the log 2023-09-28T17:49:26.2406588Z The SonarScanner CLI has finished - means 07:49 PM CET SonarQube dashboard shows the specific issue is created at September 28, 2023, at 10:59 PM CET**. This means there is a time offset, and that’s the reason I am not getting the new issue when I query immediately after the analysis.

Any help is appreciated !

Hi,

This is expected and it’s described on Background tasks

What happens after the scanner is done analyzing?

An analysis is not complete until the relevant background task has been completed. Even though the SonarScanner’s log shows EXECUTION SUCCESS, the analysis results will not be visible in the SonarQube project until the background task has been completed. After a SonarScanner has finished analyzing your code, the result of the analysis (sources, issues, metrics) is sent to SonarQube server for final processing by the compute engine. Analysis reports are queued and processed serially.

Also, at the end of analysis log you’ll see something like this:

INFO: ANALYSIS SUCCESSFUL, you can find the results at: https://sonarserver/dashboard?id=issue
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at https://sonarserver/api/ce/task?id=AYrUCDxe5mOdsjTouiSG

As you need to wait until the processing finishes, there are some options:

  • Implement your post-processing step as a webhook.
  • Or use the sonar.qualitygate.wait parameter in the analysis step to make the SonarQube Scanner wait until the background task finishes.
  • Or get the ceTaskUrl from the .scannerwork\report-task.txt file in analysis directory and query the SonarQube API yourself to check if the background task finished.
2 Likes

Thank you for the information and documentation link.