7

With each project created at my company, a new naming convention is used in Sonar. So some projects have their name as abbreviated, and some have their names as camel case, and some projects just have their names as words with spaces.

If we could pass sonar-runner a project-name parameter, then that would let us have these values set by the integrations team (2-3 people), instead of the head of each project (10+ possible people).

I feel like this may force us to create a Sonar rule for sonar properties, which is entirely too meta.

Is it possible to call something like sonar-runner --rootProject='my project' and have it? I already tried sonar-runner -DprojectName=$name.

cwallenpoole
  • 79,954
  • 26
  • 128
  • 166

2 Answers2

14

You're close, sonar.projectName is what you're looking for. Have a look at this documented list of Analysis Parameters.

Note that some SonarQube Scanners have specific behaviours, for example:

  • the scanner for Maven will in any case take values from the project definition itself (e.g. sonar.projectName is the project's <name> attribute)

  • the scanner for Gradle defaults to project.name

But when using the standard Scanner (sonar-runner) it's indeed a good idea to keep things under control by explicitly setting sonar.projectName.

Nicolas B.
  • 7,245
  • 17
  • 29
0

The example that working for me is the following:

mvn sonar:sonar \
-Dsonar.projectKey=internal_backend \
  -Dsonar.host.url=http://localhost:9000 \
  -Dsonar.login=28a95e1bdd9d31caed6d10687dd7210bcbf9ae7e
Jorge Santos Neill
  • 1,635
  • 13
  • 6