Sonar-scanner ignores projectKey given on CLI and uses sonar-project.properties instead

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension): 9.9.0 LTS, sonar-scanner 4.8.0.2856, Ubuntu 20.04
  • how is SonarQube deployed: Helm
  • what are you trying to achieve: Scan a second project
  • what have you tried so far to achieve this: It works, but there’s a bug in sonar-scanner

Description:

  • We have a sonar-project.properties with some default settings.
  • Since we’re migrating to Bazel, but haven’t fully migrated I added a <project>-bazel next to my project in SonarQube.
  • Running analysis with -Dsonar.projectKey=<project>-bazel still posts the results to <project>.
  • All other CLI options overwrite the file options (as expected).

Workaround:
Replacing sonar.projectKey in sonar-project.properties with sed works.

Hi,

It sounds likely that a sonar.projectKey override is being passed on the command line.

 
HTH,
Ann

@ganncamp I’m passing the override on the command line, but it doesn’t work. I want to override it, but I can’t.

Hi,

Can you share your sonar-project.properties file and full analysis log starting from the analysis command?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Ann