Search code examples
azure-devopsazure-pipelinessonarqube

SonarQube scanner for Javascript in Azure DevOps slower after moving to a faster computer


We have a Javascript/Typescript application that we build using Azure DevOps. As part of the pipeline we run Sonar analysis.

Previously we ran the pipeline using the standard Microsoft hosted agents and the SonarCloudAnalyze step took around 9 minutes. To speed up our builds we have moved to using self hosted agents running on MacBook pro with 16GB of RAM and a M3 CPU.

This change has substantially reduced our build time, but not for the SonarCloudAnlyze step. In fact it has got worse taking around 16 minutes.

Why would the performance have degraded even though it is running on much faster hardware? And, how might we improve the performance?

  - task: SonarCloudPrepare@1
    inputs:
      SonarCloud: 'Sonar Cloud'
      organization: 'XXX'
      scannerMode: 'CLI'
      configMode: 'file'
  - task: SonarCloudAnalyze@1
  - task: SonarCloudPublish@1
    inputs:
      pollingTimeoutSec: '300'

Solution

  • This was caused by the build having run "npm install" prior to running Sonar. Even though "node_modules" was in the "sonar.exclusions" list it appeared that these files were still being preprocessed.

    I didn't realize that the build job on the old machine didn't do the "npm install" before running Sonar.

    Resolved the issue by delete the "node_modules" folder before running sonar and the analyse step went down to 3 minutes in line with expectations.