Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to tell Sonar the project name from the command line?

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.

like image 292
cwallenpoole Avatar asked Feb 26 '16 10:02

cwallenpoole


People also ask

What is sonar project name?

sonar. projectName is purely aesthetic, while sonar. projectKey represents a different (unique) technical key that identifies the project.

How do I change the project name in SonarQube?

projectName=[new name] on the analysis command line.


1 Answers

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.

like image 155
Nicolas B. Avatar answered Oct 15 '22 15:10

Nicolas B.