SonarCloud build issue in Azure Devops PR

We set up Sonarcloud to start the code analysis when a pull request is sent through our already-existing Azure pipeline. The complete build took roughly 20 to 25 minutes with a success status prior to adding this sonar cloud task to the pipeline.

All of the pipelines were created using Azure DevOps (not on a separate virtual machine), and in addition to the solar cloud integrations, we have other integrations in our current pipelines.

After integrating this sonar into our Azure Cloud Pipelines, we are facing some issues:

  1. Build time increased due to sonar cloud integration in our azure pipelines
  2. It throws the error like “There is not enough space on the disk. Process ‘msbuild.exe’ exited with code ‘1’.” and it stops the build
  3. From my observation, when the build time is below 45 minutes, it found it returns the success status. However, if the build time exceeds 45 minutes, it returns the failed status with the above error
  4. We tried the exclusion techniques to reduce the number of files and folders. Even after this, we did not see improvement in built-time.

We want to find a solution to this soon. I want to know whether Sonarcloud is capable of working with Azure Pipelines.

Hello @DineshKumar

What are the commands that you are using for integrating with SonarCloud? Can you share your YAML file with us?

What is the configuration of your build machines? (CPU, memory, disk)?

Are you able to increase the resources of your build machines? (add more CPU, more memory, more disk)?

You can read some advice on our Troubleshooting guide.

Hello @Andrei_Epure

For integration of sonarcloud, we are using Azure devops(cloud platform),not a separate machine.

These are the commands used for sonarcloud integration.

  • task: SonarCloudPrepare@1
    SonarCloud: ‘Sonarcloud’
    organization: ‘channelassist-inc’
    scannerMode: ‘MSBuild’
    projectKey: ‘channelassist-inc_ChannelManager’
    projectName: ‘ChannelManager’
    - task: MSBuild@1
    solution: ‘**/*.sln’
    - task: SonarCloudAnalyze@1

I went through the troubleshooting ideas, and they are not suitable for the sonar cloud; please provide the steps for implementing them in the sonarcloud.

Here I attached the yaml configuration file, for your reference.
SonarCloud_Yaml_Configuration.txt (7.5 KB)

Hi @Andrei_Epure
I need a solution for this. I have shared the details which you have asked for. Can you please respond asap?

Hi @Andrei_Epure
Any update on this ticket?

Hello @DineshKumar,

Most of the troubleshooting tips are about the configuration of the machine that is running the analysis. Which ones have you tried, and which ones do you think are not suitable for SonarCloud?

Your problems seem to be related to the resources of the build agents you are using i.e. disk space and execution time. It sounds like you are using the Microsoft-hosted build agents, so you won’t be able to directly modify the agent configuration to use a more powerful machine.

However, there are a number of things you can do:

  1. increase the pipeline timeout. This is an hour by default for MS-hosted build agents but you can increase it. See the MS docs for more information.
  2. split your pipeline into multiple stages, which will be executed on different build agents and run in parallel. Again, see the MS docs on stages for more information.
  3. check there are no redundant steps in your pipeline.

Looking at the yaml file you provided, it looks like you are building all of the MSBuild solutions twice, first here:

  - task: SonarCloudPrepare@1
        inputs: ...
  - task: MSBuild@1
          solution: '**/*.sln'
    - task: SonarCloudAnalyze@1

followed a few steps later by

    - task: VSBuild@1
      displayName: 'Build ChannelManager'
        solution: '$(solution)'
        msbuildArgs: '/m:12  /p:DebugSymbols=false /p:DebugType=None /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
        platform: '$(buildPlatform)'
        configuration: '$(buildConfiguration)'
        maximumCpuCount: true       

… where $(solution) is '**/*.sln'

There are a couple of things you could try:

  1. avoid building everything twice. Instead, put the SonarCloudPrepare@1 and SonarCloudAnalyze@1 steps around the VSBuild@1 step, and drop the separate MSBuild@1 step.

  2. If that doesn’t give the behaviour you want, you could try moving the SonarCloudPrepare@1, MSBuild@1, and SonarCloudAnalyze@1 steps to a separate stage so they can run in parallel on a separate machine.