Publish Quality Gate Error "newer report has already been processed"

We use SonarCloud in Azure DevOps pipelines.
In build pipelines which have projects in a common repo we see errors when Sonar quality gates should be published:

Task : Publish Quality Gate Result
Description : Publish SonarCloud’s Quality Gate result on the Azure Pipelines build result. To be used after the actual analysis.
Version : 2.3.2
Author : sonarsource

##[error][SQ] Task failed with status FAILED, Error message: Report for commit ‘…’ can’t be processed: a newer report has already been processed, and processing older reports is not supported. The last processed report was for commit ‘…’.

This seems to happen when builds are running in parallel.

We looked at multi repo projects but that seems to count lines of code multiple times (per project in the multi repo project) when projects use references to other projects (in the same repo).

What are our options to have a correct source code line counts in an Azure DevOps repo and allow parallel builds with Sonar Analysis of projects living in the same repo?

Hi,

Are we talking about a monorepo here?

 
Ann

Hi,

sorry, yes, we tested the mono repo feature, to allow parallel pipeline builds with Sonar analysis.

Without mono repo we see the above error.

With mono repo and multiple sub projects it seems that lines of code in shared/referenced projects are counted multiple times.

Hi,

Okay, so your error scenario is that you’ve set your monorepo up in SonarCloud as a monorepo, with multiple projects, each with a distinct, and unique project id? And that when you concurrently analyze multiple projects from that monorepo, you get these errors?

 
Ann

Hi,

no, we get the error when we add the repo as one project (not mono) and then multiple DevOps pipelines build csproj files in parallel. So in this case all use the same project id.

Therefore we tried the mono repo approach. Our problem with the mono repo is, that our lines of code are counted multiple times if the same code is build in different projects of that mono repo.

So, we are searching for an option to use a mono repo where lines of code are not counted multiple times when they are used in multiple projects.

Hi,

Okay, yes. This is expected.

This is what I kinda suspected but wasn’t sure of.

So the thing to do here is to set it up as a monorepo. Do your builds like normal, and then exclude the libraries from analysis in all but one of your projects.

Because we’re talking about .NET, I need to mention that exclusions don’t work the same way for .NET that they do in other languages. You should be aware that SonarScanner for .NET will still iterate over the excluded files, and then filter those files out of the results. (Whereas other scanners don’t iterate the files at all.) This means you probably won’t save any analysis time for those exclusions, but you will save License-LoC.

 
HTH,
Ann

1 Like