SonarScanner for Azure DevOps with parallel jobs?

Hi there, we’re using Azure Devops parallel jobs and are receiving an error:
Date of analysis cannot be older than the date of the last known analysis on this project. Value: “2021-08-16T07:57:09+0000”. Latest analysis: “2021-08-16T07:57:42+0000”. It’s only possible to rebuild the past in a chronological order.

The scenario in which this is happening is very similar to what is reported here:

But since that was an old issue, I’m wonder if there’s been any new functionality which might aleviate this?

Issue is: In a similar way to the issue linked above where there is a race conditon between different pipeline runs, here there is a race condition between parallel jobs in the same build. We have two jobs that build the front end and the backend, which run in parallel after taking code from the same repository. Since they are running together and both are intended to be analysed, the issue above occurs.

Steps to replicate:

  • Create two parallel jobs in Azure devops using the Devops SonarScanner extension: (see below).
  • Ensure the organisation has the ability to run parallel jobs and the front end and backup build run at the same time
  • On the second sonar publish, the error is reported. I believe what happens is the backend SonarCloudPrepare runs, then the front end SonarCloudPrepare, all front end jobs complete (VSBuild/VSTest take a much longer time) and the backend SonarCloudPublish task is last to run.


  • Don’t use parallel jobs (we would very much like to keep this as it decreases build time)

Implementation question:

  • From the stripped down pipeline below, is it configured correctly given we have backend (C#) and front end (typescript/javascript) we’d like analysed, from the same repo but using parallel jobs to build them both?
- stage: 'BuildAndValidate'
  displayName: 'Build and validate'
- job: 'BuildAndTestBackEnd'
  displayName: 'Build and test back end'
  - task: NuGetToolInstaller@1
    displayName: 'Install NuGet'

  - task: NuGetCommand@2
    displayName: 'NuGet restore'

  - task: SonarCloudPrepare@1
      SonarCloud: 'SonarCloud'
      organization: '...'
      scannerMode: 'MSBuild'
      projectKey: '...'
      projectName: '...'

  - task: VSBuild@1
    displayName: Build solution

  - task: VSTest@2
    displayName: Run unit tests

  - task: DotNetCoreCLI@2
    displayName: Publish projects

  - task: SonarCloudAnalyze@1

  - task: SonarCloudPublish@1
      pollingTimeoutSec: '300'

- job: 'BuildAndTestFrontEnd'
  displayName: 'Build and test front end'

  - task: SonarCloudPrepare@1
      SonarCloud: 'SonarCloud'
      organization: '...'
      scannerMode: 'CLI'
      configMode: 'manual'
      cliProjectKey: '...'
      cliProjectName: '...'
      cliSources: '.'

  - task: NodeTool@0
    displayName: 'Install node'

  - task: Npm@1
    displayName: 'NPM install'

  - task: Npm@1
    displayName: 'Run tests'

  - task: PublishTestResults@2
    displayName: 'Publish test results'

  - task: PublishCodeCoverageResults@1
    displayName: 'Publish code coverage results'
  - task: Npm@1
    displayName: 'Build front end for distribution'

  - task: SonarCloudAnalyze@1

  - task: SonarCloudPublish@1
      pollingTimeoutSec: '300'

Hi @ajbrun , welcome to the community.

Unfortunately we don’t yet support multiple analysis for the same project not coming in the same chronological order.

For your scenario, would it be a possibility for you to split your backend and frontend into 2 separate SonarCloud projects ? That way you would be able to keep your parallel jobs as you have now.


1 Like