SonarQube with Azure Agent and sonar.source setting

Hi there,

we are running:

  • SonarQube: Version 7.9.2 (build 30863)
  • SonarScanner for Azure DevOps - 4.11.0 (Latest)
  • Azure Pipeline Agent (on-premise) - Version 2.174.1 (latest)

our analysis is running just fine.

But we have one question that puzzles us, that is the sonar.source setting.

We currently have the subfolder under the “_work” folder hard coded in the sonar-project.properties

# DB folder contains our code to analyze
sonar.sources=/opt/azure_pipline_agent/_work/9/s/DB/
sonar.projectBaseDir=/opt/azure_pipline_agent/_work/9/s/DB/

Issue
Randomly the Agent is creating new sub-folders, for example:
/opt/azure_pipline_agent/_work/25/a/DB/
What ended up happening is the agent put new code to another folder and the Sonar analyzer was analyzing old stale code from the hard-coded old folder.

I’m sure that hard coding the working folders is not the recommended way of configuring the path to the sources to be analyzed. The Agent should be free to create any sub-folders it needs and the Analyzer should get that folder passed over prior to starting the analysis.The documentation: https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-azure-devops/ unfortunately didn’t give us any additional hints.

Our question is:
How do we configure the sonar.source folder correctly with an Azure Agent configuration to get rid of specific sub-folders inside the internal _work folder of the Agent?

Thanks for any hints, support and tips someone could provide to us.
/R

Hi @roman.gerteis,
Have you tried to remove those parameters and run the analysis ?
Your build agent should place you in the right directory by default. Though the scanner should find the files by itself.

Kind regards,
Christophe

Hi Christophe,

I have not yet, but I’ll give it a try.

Would sonar-project.properties accept a relative path? I need to direct the scanner to a subfolder named DB.
In other words, would
sonar.source=./DB
work?

Yes it will work. Maybe it’s not clear in the doc, but this parameters is optional anyway.

Hi Christophe,

I tried it and it works. Thank you so much.

sonar.source=./DB
# sonar.projectBaseDir=<not needed>

without exactly that and it works like a charm.
Brilliant. Thank you so much.
regards
roman

1 Like

I’m always glad to hear that :slight_smile:
Happy to help :wink:

Kind regards,
Christophe

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