Error during Run Code Analysis of C++ project with Azure DevOps Pipeline

Hi everyone!

I have this sonarqube developer 9.3, sonarscanner for Azure DevOps Pipeline version 4.18 and msbuild 15.0.

I have performed sonar scanner process with Azure pipeline to analyze the code following the steps of the SonarQube guide:

  • Use Prepare Analysis on SonarQube Task setting the variables:
    • SonarQube EndPoint: define with the token to access to SonarQube
    • Choose the way to run the analysis: use standalone scanner
    • Mode: Manually provide configuration
    • Project Key: PROJECT
    • Project Name: PROJECT
    • Project Version: $(Build.BuildNumber)
    • Sources directory Root: .
    • Additional Properties: sonar.cfamily.build-wrapper-output=$(Build.SourcesDirectory)\sonar
  • Use a powershell script that execute:
    • build-wrapper-win-x86-64.exe --out-dir $(Build.SourcesDirectory)\sonar msbuild.exe solution.sln /t:Rebuild
  • Use Run Code Analysis Task
  • Use Publish Quality Gate Result Task

Where solution.sln is coded in c++ and has diferent vcprojs.

When we launch the pipeline, two first task work well, but when Run Code Analysis task is running happens an error:

##[error]: Error during SonarScanner Execution
ERROR: Error during SonarScanner execution
##[error]java.lang.IllegalStateException: java.nio.file.NoSuchFileException: $(Build.SourcesDirectory)\sonar\build-wrapper-dump-json

It’s important to said that json file doesn’t exist in that folder, I have put different folders but that file never create during the build task.

On the other side, if I do the steps with with SonarScanner via command line in local, the measures was correctly analyzed and published in SonarQube server.

Can anyone help me with this problem?

Thanks in advance.

Hi @monica,

We have a sample repository that performs an analysis of a C++ project on azure, maybe having a look at it might help you setting this up? GitHub - sonarsource-cfamily-examples/windows-msbuild-azure-sq: An example C++ repository built with MSBuild on Windows using Azure Pipelines and analyzed on SonarQube

That being said, I have a few questions:

  • Do you execute all the steps on the same agent, as required?
  • Can you manually see a build-wrapper-dump.json generated when you run the powershell?
  • I’m surprised that the error message mentions build-wrapper-dump-json and not build-wrapper-dump.json. Does it ring any bell?

Let me know if this helps you!

Hi @JolyLoic,

I saw that sample before and I configured the different tasks like it said.

To your questions:

  • Yes, all steps are done by the same agent.
  • Yes, when I run manually powershell script, I can see the json file.
  • Sorry, you are right. I spelled it wrong, the error message is with build-wrapper-dump.json

Thanks in advance.

Hi @monica,

Can you send me the logs that you have, as well as your azure-pipelines.yml file?

Hello @monica, and thank you for the files you have provided to me. Here are the things I can see in them:

  • You only provided me the log for the analysis step, I don’t see how you run the Powershell script.
  • In the JSON corresponding to the configuration of the task, I could not see any build wrapped by the build wrapper either. The only PowerShell present was some placeholder
  • You set the build wrapper path to C:\\Program Files (x86)\\sonarTools\\build-wrapper-win-x86\\sonar. Since this is a path that should be written to, putting it in a folder that is usually only accessible in admin mode might be a cause of problems.

Hope this helps,

Hello @JolyLoic,

I’m sorry for answering delay.

I answer your questions below:

  • I send you privately powershell build task.
  • I put that path but I taste with others (agent path, documents path…) and always happens the same, the json file doesn’t create.

Thanks for your comments.

Hello @JolyLoic,

I send to you privately more information with different logs.

Hope it helps for the solution.
Monica.

For information, this issue was solved through direct messages. There was a typo in one script.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.